@h3ravel/console 11.1.0 → 11.2.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 +69 -1
- package/bin/fire.js +69 -1
- package/dist/{Utils-B1kpj9-1.cjs → Utils-CpiQZ3n9.cjs} +7 -15
- package/dist/Utils-CpiQZ3n9.cjs.map +1 -0
- package/dist/{Utils-DAJvoXlr.js → Utils-Dvclc4Pc.js} +2 -15
- package/dist/Utils-Dvclc4Pc.js.map +1 -0
- package/dist/{Utils-DxnHOGMz.d.ts → Utils-cBgwEyTl.d.ts} +1 -3
- package/dist/{Utils-7OrjoB1C.d.cts → Utils-rIdzILgO.d.cts} +1 -3
- package/dist/Utils.cjs +1 -1
- package/dist/Utils.d.cts +1 -1
- package/dist/Utils.d.ts +1 -1
- package/dist/Utils.js +1 -1
- package/dist/index.cjs +336 -436
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -137
- package/dist/index.d.ts +34 -137
- package/dist/index.js +331 -430
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/Utils-B1kpj9-1.cjs.map +0 -1
- package/dist/Utils-DAJvoXlr.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,160 +1,163 @@
|
|
|
1
|
-
const require_Utils = require('./Utils-
|
|
1
|
+
const require_Utils = require('./Utils-CpiQZ3n9.cjs');
|
|
2
|
+
let fs_promises = require("fs/promises");
|
|
3
|
+
fs_promises = require_Utils.__toESM(fs_promises);
|
|
2
4
|
let path = require("path");
|
|
3
5
|
path = require_Utils.__toESM(path);
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
let
|
|
7
|
-
|
|
6
|
+
let __h3ravel_core = require("@h3ravel/core");
|
|
7
|
+
__h3ravel_core = require_Utils.__toESM(__h3ravel_core);
|
|
8
|
+
let __h3ravel_shared = require("@h3ravel/shared");
|
|
9
|
+
__h3ravel_shared = require_Utils.__toESM(__h3ravel_shared);
|
|
8
10
|
let node_fs_promises = require("node:fs/promises");
|
|
9
11
|
node_fs_promises = require_Utils.__toESM(node_fs_promises);
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
+
let __h3ravel_support = require("@h3ravel/support");
|
|
13
|
+
__h3ravel_support = require_Utils.__toESM(__h3ravel_support);
|
|
12
14
|
let dayjs = require("dayjs");
|
|
13
15
|
dayjs = require_Utils.__toESM(dayjs);
|
|
14
16
|
let node_fs = require("node:fs");
|
|
15
17
|
node_fs = require_Utils.__toESM(node_fs);
|
|
16
18
|
let node_path = require("node:path");
|
|
17
19
|
node_path = require_Utils.__toESM(node_path);
|
|
18
|
-
let __h3ravel_arquebus_migrations = require("@h3ravel/arquebus/migrations");
|
|
19
|
-
__h3ravel_arquebus_migrations = require_Utils.__toESM(__h3ravel_arquebus_migrations);
|
|
20
|
-
let __h3ravel_database = require("@h3ravel/database");
|
|
21
|
-
__h3ravel_database = require_Utils.__toESM(__h3ravel_database);
|
|
22
|
-
let __h3ravel_core = require("@h3ravel/core");
|
|
23
|
-
__h3ravel_core = require_Utils.__toESM(__h3ravel_core);
|
|
24
|
-
require("@h3ravel/console");
|
|
25
20
|
require("@h3ravel/http");
|
|
26
21
|
require("@h3ravel/router");
|
|
22
|
+
require("@h3ravel/database");
|
|
27
23
|
require("@h3ravel/cache");
|
|
28
24
|
require("@h3ravel/queue");
|
|
29
25
|
require("@h3ravel/mail");
|
|
30
26
|
require("@h3ravel/config");
|
|
31
|
-
let __h3ravel_shared = require("@h3ravel/shared");
|
|
32
|
-
__h3ravel_shared = require_Utils.__toESM(__h3ravel_shared);
|
|
33
27
|
let commander = require("commander");
|
|
34
28
|
commander = require_Utils.__toESM(commander);
|
|
35
29
|
let child_process = require("child_process");
|
|
36
30
|
child_process = require_Utils.__toESM(child_process);
|
|
31
|
+
let tsdown = require("tsdown");
|
|
32
|
+
tsdown = require_Utils.__toESM(tsdown);
|
|
37
33
|
|
|
38
34
|
//#region src/Commands/Command.ts
|
|
39
|
-
var Command = class {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
var Command = class extends __h3ravel_core.ConsoleCommand {};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/logo.ts
|
|
39
|
+
const logo = String.raw`
|
|
40
|
+
111
|
|
41
|
+
111111111
|
|
42
|
+
1111111111 111111
|
|
43
|
+
111111 111 111111
|
|
44
|
+
111111 111 111111
|
|
45
|
+
11111 111 11111
|
|
46
|
+
1111111 111 1111111
|
|
47
|
+
111 11111 111 111111 111 1111 1111 11111111 1111
|
|
48
|
+
111 11111 1111 111111 111 1111 1111 1111 11111 1111
|
|
49
|
+
111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
|
|
50
|
+
111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
|
|
51
|
+
111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
|
|
52
|
+
111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
|
|
53
|
+
111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
|
|
54
|
+
1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
|
|
55
|
+
11011 111111 11 11111
|
|
56
|
+
111111 11101 111111
|
|
57
|
+
111111 111 111111
|
|
58
|
+
111111 111 111111
|
|
59
|
+
111111111
|
|
60
|
+
110
|
|
61
|
+
`;
|
|
62
|
+
const altLogo = String.raw`
|
|
63
|
+
_ _ _____ _
|
|
64
|
+
| | | |___ / _ __ __ ___ _____| |
|
|
65
|
+
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
66
|
+
| _ |___) | | | (_| |\ V / __/ |
|
|
67
|
+
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
68
|
+
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/Commands/ListCommand.ts
|
|
73
|
+
var ListCommand = class extends Command {
|
|
44
74
|
/**
|
|
45
75
|
* The name and signature of the console command.
|
|
46
76
|
*
|
|
47
77
|
* @var string
|
|
48
78
|
*/
|
|
49
|
-
signature;
|
|
50
|
-
/**
|
|
51
|
-
* A dictionary of signatures or what not.
|
|
52
|
-
*
|
|
53
|
-
* @var object
|
|
54
|
-
*/
|
|
55
|
-
dictionary = {};
|
|
79
|
+
signature = "list";
|
|
56
80
|
/**
|
|
57
81
|
* The console command description.
|
|
58
82
|
*
|
|
59
83
|
* @var string
|
|
60
84
|
*/
|
|
61
|
-
description;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return this.input.arguments;
|
|
85
|
+
description = "List all available commands";
|
|
86
|
+
async handle() {
|
|
87
|
+
const options = [{
|
|
88
|
+
short: "-h",
|
|
89
|
+
long: "--help",
|
|
90
|
+
description: "Display help for the given command. When no command is given display help for the list command"
|
|
91
|
+
}].concat(this.program.options).map((e) => {
|
|
92
|
+
return __h3ravel_shared.Logger.describe(__h3ravel_shared.Logger.log(" " + [e.short, e.long].filter((e$1) => !!e$1).join(", "), "green", false), e.description, 25, false).join("");
|
|
93
|
+
});
|
|
94
|
+
const grouped = this.program.commands.map((e) => {
|
|
95
|
+
return __h3ravel_shared.Logger.describe(__h3ravel_shared.Logger.log(" " + e.name(), "green", false), e.description(), 25, false).join("");
|
|
96
|
+
}).reduce((acc, cmd) => {
|
|
97
|
+
/** strip colors before checking prefix */
|
|
98
|
+
const clean = cmd.replace(/\x1b\[\d+m/g, "");
|
|
99
|
+
const prefix = clean.includes(":") ? clean.split(":")[0].trim() : "__root__";
|
|
100
|
+
acc[prefix] ??= [];
|
|
101
|
+
/** keep original with colors */
|
|
102
|
+
acc[prefix].push(cmd);
|
|
103
|
+
return acc;
|
|
104
|
+
}, {});
|
|
105
|
+
const list = Object.entries(grouped).map(([group, cmds]) => {
|
|
106
|
+
const label = group === "__root__" ? "" : group;
|
|
107
|
+
return [__h3ravel_shared.Logger.log(label, "yellow", false), cmds.join("\n")].join("\n");
|
|
108
|
+
});
|
|
109
|
+
/** Ootput the app version */
|
|
110
|
+
__h3ravel_shared.Logger.log([["H3ravel Framework", "white"], [this.kernel.modulePackage.version, "green"]], " ");
|
|
111
|
+
console.log("");
|
|
112
|
+
console.log(altLogo);
|
|
113
|
+
console.log("");
|
|
114
|
+
__h3ravel_shared.Logger.log("Usage:", "yellow");
|
|
115
|
+
__h3ravel_shared.Logger.log(" command [options] [arguments]", "white");
|
|
116
|
+
console.log("");
|
|
117
|
+
/** Ootput the options */
|
|
118
|
+
__h3ravel_shared.Logger.log("Options:", "yellow");
|
|
119
|
+
console.log(options.join("\n").trim());
|
|
120
|
+
console.log("");
|
|
121
|
+
/** Ootput the commands */
|
|
122
|
+
__h3ravel_shared.Logger.log("Available Commands:", "yellow");
|
|
123
|
+
console.log(list.join("\n\n").trim());
|
|
101
124
|
}
|
|
102
125
|
};
|
|
103
126
|
|
|
104
127
|
//#endregion
|
|
105
|
-
//#region
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`;
|
|
128
|
+
//#region ../filesystem/dist/index.js
|
|
129
|
+
var Helpers = class {
|
|
130
|
+
static findModulePkg(moduleId, cwd) {
|
|
131
|
+
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
132
|
+
let packageName = "";
|
|
133
|
+
if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
|
|
134
|
+
packageName += parts.shift();
|
|
135
|
+
const packageJson = path.default.join(cwd ?? process.cwd(), "node_modules", packageName);
|
|
136
|
+
const resolved = this.findUpConfig(packageJson, "package", ["json"]);
|
|
137
|
+
if (!resolved) return;
|
|
138
|
+
return path.default.join(path.default.dirname(resolved), parts.join("/"));
|
|
139
|
+
}
|
|
118
140
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* @
|
|
141
|
+
* Check if file exists
|
|
142
|
+
*
|
|
143
|
+
* @param path
|
|
144
|
+
* @returns
|
|
122
145
|
*/
|
|
123
|
-
|
|
124
|
-
async handle() {
|
|
146
|
+
static async fileExists(path$1$1) {
|
|
125
147
|
try {
|
|
126
|
-
await
|
|
127
|
-
|
|
128
|
-
|
|
148
|
+
await (0, fs_promises.access)(path$1$1);
|
|
149
|
+
return true;
|
|
150
|
+
} catch {
|
|
151
|
+
return false;
|
|
129
152
|
}
|
|
130
153
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
EXTENDED_DEBUG: this.option("debug") ? "true" : "false",
|
|
139
|
-
CLI_BUILD: "false",
|
|
140
|
-
NODE_ENV: "development",
|
|
141
|
-
SRC_PATH: outDir$1,
|
|
142
|
-
HOSTNAME: host,
|
|
143
|
-
RETRIES: tries,
|
|
144
|
-
PORT: port
|
|
145
|
-
};
|
|
146
|
-
await (0, execa.execa)(pm, [
|
|
147
|
-
"tsdown",
|
|
148
|
-
"--silent",
|
|
149
|
-
"--config-loader",
|
|
150
|
-
"unconfig",
|
|
151
|
-
"-c",
|
|
152
|
-
"tsdown.default.config.ts"
|
|
153
|
-
], {
|
|
154
|
-
stdout: "inherit",
|
|
155
|
-
stderr: "inherit",
|
|
156
|
-
cwd: base_path(),
|
|
157
|
-
env: Object.assign({}, process.env, ENV_VARS)
|
|
154
|
+
static findUpConfig(cwd, name, extensions) {
|
|
155
|
+
return require_Utils.sync_default(cwd, (_dir, names) => {
|
|
156
|
+
for (const ext of extensions) {
|
|
157
|
+
const filename = `${name}.${ext}`;
|
|
158
|
+
if (names.includes(filename)) return filename;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
158
161
|
});
|
|
159
162
|
}
|
|
160
163
|
};
|
|
@@ -168,12 +171,37 @@ var MakeCommand = class extends Command {
|
|
|
168
171
|
* @var string
|
|
169
172
|
*/
|
|
170
173
|
signature = `#make:
|
|
171
|
-
{controller :
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
{controller : Create a new controller class.
|
|
175
|
+
| {--a|api : Exclude the create and edit methods from the controller}
|
|
176
|
+
| {--m|model= : Generate a resource controller for the given model}
|
|
177
|
+
| {--r|resource : Generate a resource controller class}
|
|
178
|
+
| {--force : Create the controller even if it already exists}
|
|
179
|
+
}
|
|
180
|
+
{resource : Create a new resource.
|
|
181
|
+
| {--c|collection : Create a resource collection}
|
|
182
|
+
| {--force : Create the resource even if it already exists}
|
|
183
|
+
}
|
|
184
|
+
{migration : Generates a new database migration class.
|
|
185
|
+
| {--l|type=ts : The file type to generate}
|
|
186
|
+
| {--t|table : The table to migrate}
|
|
187
|
+
| {--c|create : The table to be created}
|
|
188
|
+
}
|
|
189
|
+
{factory : Create a new model factory.}
|
|
190
|
+
{seeder : Create a new seeder class.}
|
|
191
|
+
{view : Create a new view.
|
|
192
|
+
| {--force : Create the view even if it already exists}
|
|
193
|
+
}
|
|
194
|
+
{model : Create a new Eloquent model class.
|
|
195
|
+
| {--api : Indicates if the generated controller should be an API resource controller}
|
|
196
|
+
| {--c|controller : Create a new controller for the model}
|
|
197
|
+
| {--f|factory : Create a new factory for the model}
|
|
198
|
+
| {--m|migration : Create a new migration file for the model}
|
|
199
|
+
| {--r|resource : Indicates if the generated controller should be a resource controller}
|
|
200
|
+
| {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
|
|
201
|
+
| {--s|seed : Create a new seeder for the model}
|
|
202
|
+
| {--t|type=ts : The file type to generate}
|
|
203
|
+
| {--force : Create the model even if it already exists}
|
|
204
|
+
}
|
|
177
205
|
{^name : The name of the [name] to generate}
|
|
178
206
|
`;
|
|
179
207
|
/**
|
|
@@ -183,39 +211,41 @@ var MakeCommand = class extends Command {
|
|
|
183
211
|
*/
|
|
184
212
|
description = "Generate component classes";
|
|
185
213
|
async handle() {
|
|
186
|
-
const command = this.dictionary.baseCommand;
|
|
214
|
+
const command = this.dictionary.baseCommand ?? this.dictionary.name;
|
|
187
215
|
const methods = {
|
|
188
216
|
controller: "makeController",
|
|
189
217
|
resource: "makeResource",
|
|
190
218
|
migration: "makeMigration",
|
|
191
219
|
factory: "makeFactory",
|
|
192
220
|
seeder: "makeSeeder",
|
|
193
|
-
model: "makeModel"
|
|
221
|
+
model: "makeModel",
|
|
222
|
+
view: "makeView"
|
|
194
223
|
};
|
|
195
224
|
try {
|
|
196
225
|
await this?.[methods[command]]();
|
|
197
226
|
} catch (e) {
|
|
198
|
-
|
|
227
|
+
__h3ravel_shared.Logger.error(e);
|
|
199
228
|
}
|
|
200
229
|
}
|
|
201
230
|
/**
|
|
202
|
-
*
|
|
231
|
+
* Create a new controller class.
|
|
203
232
|
*/
|
|
204
233
|
async makeController() {
|
|
205
234
|
const type = this.option("api") ? "-resource" : "";
|
|
206
235
|
const name = this.argument("name");
|
|
207
236
|
const force = this.option("force");
|
|
208
237
|
const path$5 = node_path.default.join(app_path("Http/Controllers"), name + ".ts");
|
|
209
|
-
const crtlrPath =
|
|
238
|
+
const crtlrPath = Helpers.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
|
|
210
239
|
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
|
|
211
|
-
|
|
240
|
+
/** Check if the controller already exists */
|
|
241
|
+
if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
|
|
212
242
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
213
243
|
stub = stub.replace(/{{ name }}/g, name);
|
|
214
244
|
await (0, node_fs_promises.writeFile)(path$5, stub);
|
|
215
|
-
|
|
245
|
+
__h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
|
|
216
246
|
}
|
|
217
247
|
makeResource() {
|
|
218
|
-
|
|
248
|
+
__h3ravel_shared.Logger.success("Resource support is not yet available");
|
|
219
249
|
}
|
|
220
250
|
/**
|
|
221
251
|
* Generate a new database migration class
|
|
@@ -239,16 +269,22 @@ var MakeCommand = class extends Command {
|
|
|
239
269
|
const stubPath = node_path.default.join(crtlrPath, this.getMigrationStubName(table, create));
|
|
240
270
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
241
271
|
if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
242
|
-
|
|
272
|
+
__h3ravel_shared.Logger.info("INFO: Creating Migration");
|
|
243
273
|
await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$5));
|
|
244
274
|
await (0, node_fs_promises.writeFile)(path$5, stub);
|
|
245
|
-
|
|
275
|
+
__h3ravel_shared.Logger.split("INFO: Migration Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
|
|
246
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Create a new model factory
|
|
279
|
+
*/
|
|
247
280
|
makeFactory() {
|
|
248
|
-
|
|
281
|
+
__h3ravel_shared.Logger.success("Factory support is not yet available");
|
|
249
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Create a new seeder class
|
|
285
|
+
*/
|
|
250
286
|
makeSeeder() {
|
|
251
|
-
|
|
287
|
+
__h3ravel_shared.Logger.success("Seeder support is not yet available");
|
|
252
288
|
}
|
|
253
289
|
/**
|
|
254
290
|
* Generate a new Arquebus model class
|
|
@@ -256,13 +292,29 @@ var MakeCommand = class extends Command {
|
|
|
256
292
|
async makeModel() {
|
|
257
293
|
const type = this.option("type", "ts");
|
|
258
294
|
const name = this.argument("name");
|
|
259
|
-
const
|
|
295
|
+
const force = this.argument("force");
|
|
296
|
+
const path$5 = node_path.default.join(app_path("Models"), name.toLowerCase(), "." + type);
|
|
297
|
+
/** Check if the model already exists */
|
|
298
|
+
if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
|
|
260
299
|
const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
261
300
|
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/model-${type}.stub`);
|
|
262
301
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
263
302
|
stub = stub.replace(/{{ name }}/g, name);
|
|
264
303
|
await (0, node_fs_promises.writeFile)(path$5, stub);
|
|
265
|
-
|
|
304
|
+
__h3ravel_shared.Logger.split("INFO: Model Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Create a new view.
|
|
308
|
+
*/
|
|
309
|
+
async makeView() {
|
|
310
|
+
const name = this.argument("name");
|
|
311
|
+
const force = this.option("force");
|
|
312
|
+
const path$5 = node_path.default.join(base_path("src/resources/views"), name + ".edge");
|
|
313
|
+
if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$5, "/"), { recursive: true });
|
|
314
|
+
/** Check if the view already exists */
|
|
315
|
+
if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
|
|
316
|
+
await (0, node_fs_promises.writeFile)(path$5, `{{-- src/resources/views/${name}.edge --}}`);
|
|
317
|
+
__h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
|
|
266
318
|
}
|
|
267
319
|
/**
|
|
268
320
|
* Ge the database migration file name
|
|
@@ -281,181 +333,6 @@ var MakeCommand = class extends Command {
|
|
|
281
333
|
}
|
|
282
334
|
};
|
|
283
335
|
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/Commands/MigrateCommand.ts
|
|
286
|
-
var MigrateCommand = class extends Command {
|
|
287
|
-
/**
|
|
288
|
-
* The current database connection
|
|
289
|
-
*/
|
|
290
|
-
connection;
|
|
291
|
-
/**
|
|
292
|
-
* The base path for all database operations
|
|
293
|
-
*/
|
|
294
|
-
databasePath = database_path();
|
|
295
|
-
/**
|
|
296
|
-
* The name and signature of the console command.
|
|
297
|
-
*
|
|
298
|
-
* @var string
|
|
299
|
-
*/
|
|
300
|
-
signature = `migrate:
|
|
301
|
-
{fresh : Drop all tables and re-run all migrations.}
|
|
302
|
-
{install : Create the migration repository.}
|
|
303
|
-
{refresh : Reset and re-run all migrations.}
|
|
304
|
-
{reset : Rollback all database migrations.}
|
|
305
|
-
{rollback : Rollback the last database migration.}
|
|
306
|
-
{status : Show the status of each migration.}
|
|
307
|
-
{publish : Publish any migration files from installed packages. | {package : The package to publish migrations from}}
|
|
308
|
-
{^--s|seed : Seed the database}
|
|
309
|
-
{^--c|connection=mysql : The database connection to use}
|
|
310
|
-
`;
|
|
311
|
-
/**
|
|
312
|
-
* The console command description.
|
|
313
|
-
*
|
|
314
|
-
* @var string
|
|
315
|
-
*/
|
|
316
|
-
description = "Run all pending migrations.";
|
|
317
|
-
/**
|
|
318
|
-
* Execute the console command.
|
|
319
|
-
*/
|
|
320
|
-
async handle() {
|
|
321
|
-
const command = this.dictionary.name ?? this.dictionary.baseCommand;
|
|
322
|
-
this.connection = Object.entries((0, __h3ravel_database.arquebusConfig)(config("database"))).find(([client]) => client === config("database.default"))?.at(1);
|
|
323
|
-
this.connection.migrations = {
|
|
324
|
-
path: "migrations",
|
|
325
|
-
table: "migrations"
|
|
326
|
-
};
|
|
327
|
-
await this?.[{
|
|
328
|
-
migrate: "migrateRun",
|
|
329
|
-
fresh: "migrateFresh",
|
|
330
|
-
install: "migrateInstall",
|
|
331
|
-
refresh: "migrateRefresh",
|
|
332
|
-
reset: "migrateReset",
|
|
333
|
-
rollback: "migrateRollback",
|
|
334
|
-
status: "migrateStatus",
|
|
335
|
-
publish: "migratePublish"
|
|
336
|
-
}[command]]();
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Run all pending migrations.
|
|
340
|
-
*/
|
|
341
|
-
async migrateRun() {
|
|
342
|
-
try {
|
|
343
|
-
await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).run(this.connection, this.options(), true);
|
|
344
|
-
} catch (e) {
|
|
345
|
-
this.kernel.output.error("ERROR: " + e);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Drop all tables and re-run all migrations.
|
|
350
|
-
*/
|
|
351
|
-
async migrateFresh() {
|
|
352
|
-
try {
|
|
353
|
-
await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).fresh(this.connection, this.options(), true);
|
|
354
|
-
} catch (e) {
|
|
355
|
-
this.kernel.output.error("ERROR: " + e);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Create the migration repository.
|
|
360
|
-
*/
|
|
361
|
-
async migrateInstall() {
|
|
362
|
-
try {
|
|
363
|
-
const migrate = new __h3ravel_arquebus_migrations.Migrate(this.databasePath);
|
|
364
|
-
const { migrator } = await migrate.setupConnection(this.connection);
|
|
365
|
-
await migrate.prepareDatabase(migrator);
|
|
366
|
-
this.kernel.output.success(`Migration repository installed.`);
|
|
367
|
-
} catch (e) {
|
|
368
|
-
this.kernel.output.error("ERROR: " + e);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Reset and re-run all migrations.
|
|
373
|
-
*/
|
|
374
|
-
async migrateRefresh() {
|
|
375
|
-
try {
|
|
376
|
-
await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).refresh(this.connection, this.options(), true);
|
|
377
|
-
} catch (e) {
|
|
378
|
-
this.kernel.output.error("ERROR: " + e);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Rollback all database migrations.
|
|
383
|
-
*/
|
|
384
|
-
async migrateReset() {
|
|
385
|
-
try {
|
|
386
|
-
await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).reset(this.connection, this.options(), true);
|
|
387
|
-
} catch (e) {
|
|
388
|
-
this.kernel.output.error("ERROR: " + e);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Rollback the last database migration.
|
|
393
|
-
*/
|
|
394
|
-
async migrateRollback() {
|
|
395
|
-
try {
|
|
396
|
-
await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).rollback(this.connection, this.options(), true);
|
|
397
|
-
} catch (e) {
|
|
398
|
-
this.kernel.output.error("ERROR: " + e);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Show the status of each migration.
|
|
403
|
-
*/
|
|
404
|
-
async migrateStatus() {
|
|
405
|
-
const migrations = await new __h3ravel_arquebus_migrations.Migrate(this.databasePath, void 0, (msg, sts) => {
|
|
406
|
-
const hint = this.kernel.output.parse([[" Did you forget to run", "white"], ["`musket migrate:install`?", "grey"]], " ", false);
|
|
407
|
-
if (sts) this.kernel.output[sts](msg + hint, sts === "error", true);
|
|
408
|
-
}).status(this.connection, this.options(), true);
|
|
409
|
-
try {
|
|
410
|
-
if (migrations.length > 0) {
|
|
411
|
-
this.kernel.output.twoColumnLog("Migration name", "Batch / Status");
|
|
412
|
-
migrations.forEach((migration) => {
|
|
413
|
-
const status = migration.ran ? `[${migration.batch}] ${chalk.default.green("Ran")}` : chalk.default.yellow("Pending");
|
|
414
|
-
this.kernel.output.twoColumnLog(migration.name, status);
|
|
415
|
-
});
|
|
416
|
-
} else this.kernel.output.info("No migrations found");
|
|
417
|
-
} catch (e) {
|
|
418
|
-
this.kernel.output.error(["ERROR: " + e, "Did you run musket migrate:install"]);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Publish any migration files from installed packages.
|
|
423
|
-
*/
|
|
424
|
-
async migratePublish() {
|
|
425
|
-
const name = this.argument("package");
|
|
426
|
-
try {
|
|
427
|
-
/** Find the requested package */
|
|
428
|
-
const packagePath = require_Utils.Utils.findModulePkg(name) ?? null;
|
|
429
|
-
if (!packagePath) throw new Error("Package not found");
|
|
430
|
-
/** Get the package,json and instanciate the migration creator */
|
|
431
|
-
const pkgJson = await import(node_path.default.join(packagePath, "package.json"));
|
|
432
|
-
const creator = new __h3ravel_arquebus_migrations.MigrationCreator(node_path.default.join(packagePath, pkgJson.migrations ?? "migrations"));
|
|
433
|
-
const info = this.kernel.output.parse([[" Publishing migrations from", "white"], [`${pkgJson.name}@${pkgJson.version}`, chalk.default.italic.gray]], " ", false);
|
|
434
|
-
this.kernel.output.info(`INFO: ${info}`);
|
|
435
|
-
try {
|
|
436
|
-
/** Publish any existing migrations */
|
|
437
|
-
await creator.publish(this.databasePath, (fileName) => {
|
|
438
|
-
this.kernel.output.twoColumnLog(fileName, chalk.default.green("PUBLISHED"));
|
|
439
|
-
});
|
|
440
|
-
} catch {
|
|
441
|
-
this.kernel.output.error([`ERROR: ${name} has no publishable migrations.`]);
|
|
442
|
-
}
|
|
443
|
-
} catch (e) {
|
|
444
|
-
const hint = this.kernel.output.parse([[" Did you forget to run", "white"], [`\`${await require_Utils.Utils.installCommand(name)}\``, "grey"]], " ", false);
|
|
445
|
-
const error = this.kernel.output.parse([
|
|
446
|
-
["Package `", "white"],
|
|
447
|
-
[name, "grey"],
|
|
448
|
-
["` not found", "white"]
|
|
449
|
-
], "", false);
|
|
450
|
-
this.kernel.output.error([
|
|
451
|
-
"ERROR: " + error,
|
|
452
|
-
hint + "?",
|
|
453
|
-
String(e)
|
|
454
|
-
]);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
|
|
459
336
|
//#endregion
|
|
460
337
|
//#region src/Signature.ts
|
|
461
338
|
var Signature = class Signature {
|
|
@@ -488,7 +365,7 @@ var Signature = class Signature {
|
|
|
488
365
|
continue;
|
|
489
366
|
}
|
|
490
367
|
const namePart = content.substring(0, colonIndex).trim();
|
|
491
|
-
|
|
368
|
+
const rest = content.substring(colonIndex + 1).trim();
|
|
492
369
|
/**
|
|
493
370
|
* Check for nested options after '|'
|
|
494
371
|
*/
|
|
@@ -620,13 +497,107 @@ var Signature = class Signature {
|
|
|
620
497
|
}
|
|
621
498
|
};
|
|
622
499
|
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0/node_modules/@rollup/plugin-run/dist/es/index.js
|
|
502
|
+
function run(opts = {}) {
|
|
503
|
+
let input;
|
|
504
|
+
let proc;
|
|
505
|
+
const args = opts.args || [];
|
|
506
|
+
const allowRestarts = opts.allowRestarts || false;
|
|
507
|
+
const overrideInput = opts.input;
|
|
508
|
+
const forkOptions = opts.options || opts;
|
|
509
|
+
delete forkOptions.args;
|
|
510
|
+
delete forkOptions.allowRestarts;
|
|
511
|
+
return {
|
|
512
|
+
name: "run",
|
|
513
|
+
buildStart(options) {
|
|
514
|
+
let inputs = overrideInput !== null && overrideInput !== void 0 ? overrideInput : options.input;
|
|
515
|
+
if (typeof inputs === "string") inputs = [inputs];
|
|
516
|
+
if (typeof inputs === "object") inputs = Object.values(inputs);
|
|
517
|
+
if (inputs.length > 1) throw new Error(`@rollup/plugin-run must have a single entry point; consider setting the \`input\` option`);
|
|
518
|
+
input = (0, path.resolve)(inputs[0]);
|
|
519
|
+
},
|
|
520
|
+
generateBundle(_outputOptions, _bundle, isWrite) {
|
|
521
|
+
if (!isWrite) this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`);
|
|
522
|
+
},
|
|
523
|
+
writeBundle(outputOptions, bundle) {
|
|
524
|
+
const forkBundle = (dir$1, entryFileName$1) => {
|
|
525
|
+
if (proc) proc.kill();
|
|
526
|
+
proc = (0, child_process.fork)((0, path.join)(dir$1, entryFileName$1), args, forkOptions);
|
|
527
|
+
};
|
|
528
|
+
const dir = outputOptions.dir || (0, path.dirname)(outputOptions.file);
|
|
529
|
+
const entryFileName = Object.keys(bundle).find((fileName) => {
|
|
530
|
+
const chunk = bundle[fileName];
|
|
531
|
+
return chunk.isEntry && chunk.facadeModuleId === input;
|
|
532
|
+
});
|
|
533
|
+
if (entryFileName) {
|
|
534
|
+
forkBundle(dir, entryFileName);
|
|
535
|
+
if (allowRestarts) {
|
|
536
|
+
process.stdin.resume();
|
|
537
|
+
process.stdin.setEncoding("utf8");
|
|
538
|
+
process.stdin.on("data", (data) => {
|
|
539
|
+
const line = data.toString().trim().toLowerCase();
|
|
540
|
+
if (line === "rs" || line === "restart" || data.toString().charCodeAt(0) === 11) forkBundle(dir, entryFileName);
|
|
541
|
+
else if (line === "cls" || line === "clear" || data.toString().charCodeAt(0) === 12) console.clear();
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
} else this.error(`@rollup/plugin-run could not find output chunk`);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/TsdownConfig.ts
|
|
551
|
+
const env = process.env.NODE_ENV || "development";
|
|
552
|
+
const outDir = env === "development" ? ".h3ravel/serve" : "dist";
|
|
553
|
+
const TsDownConfig = {
|
|
554
|
+
outDir,
|
|
555
|
+
entry: ["src/**/*.ts"],
|
|
556
|
+
format: ["esm"],
|
|
557
|
+
target: "node22",
|
|
558
|
+
sourcemap: env === "development",
|
|
559
|
+
clean: true,
|
|
560
|
+
shims: true,
|
|
561
|
+
copy: [
|
|
562
|
+
{
|
|
563
|
+
from: "public",
|
|
564
|
+
to: outDir
|
|
565
|
+
},
|
|
566
|
+
"src/resources",
|
|
567
|
+
"src/database"
|
|
568
|
+
],
|
|
569
|
+
env: env === "development" ? {
|
|
570
|
+
NODE_ENV: env,
|
|
571
|
+
SRC_PATH: outDir
|
|
572
|
+
} : {},
|
|
573
|
+
watch: env === "development" && process.env.CLI_BUILD !== "true" ? [
|
|
574
|
+
".env",
|
|
575
|
+
".env.*",
|
|
576
|
+
"src",
|
|
577
|
+
"../../packages"
|
|
578
|
+
] : false,
|
|
579
|
+
dts: false,
|
|
580
|
+
logLevel: "silent",
|
|
581
|
+
nodeProtocol: true,
|
|
582
|
+
skipNodeModulesBundle: true,
|
|
583
|
+
plugins: env === "development" && process.env.CLI_BUILD !== "true" ? [run({
|
|
584
|
+
env: Object.assign({}, process.env, {
|
|
585
|
+
NODE_ENV: env,
|
|
586
|
+
SRC_PATH: outDir
|
|
587
|
+
}),
|
|
588
|
+
execArgv: ["-r", "source-map-support/register"],
|
|
589
|
+
allowRestarts: false,
|
|
590
|
+
input: process.cwd() + "/src/server.ts"
|
|
591
|
+
})] : []
|
|
592
|
+
};
|
|
593
|
+
var TsdownConfig_default = TsDownConfig;
|
|
594
|
+
|
|
623
595
|
//#endregion
|
|
624
596
|
//#region src/Musket.ts
|
|
625
597
|
/**
|
|
626
598
|
* Musket is H3ravel's CLI tool
|
|
627
599
|
*/
|
|
628
600
|
var Musket = class Musket {
|
|
629
|
-
output = __h3ravel_shared.Logger.log();
|
|
630
601
|
commands = [];
|
|
631
602
|
constructor(app, kernel) {
|
|
632
603
|
this.app = app;
|
|
@@ -638,11 +609,7 @@ var Musket = class Musket {
|
|
|
638
609
|
return this.initialize();
|
|
639
610
|
}
|
|
640
611
|
loadBaseCommands() {
|
|
641
|
-
[
|
|
642
|
-
new FireCommand(this.app, this.kernel),
|
|
643
|
-
new MakeCommand(this.app, this.kernel),
|
|
644
|
-
new MigrateCommand(this.app, this.kernel)
|
|
645
|
-
].forEach((e) => this.addCommand(e));
|
|
612
|
+
[new MakeCommand(this.app, this.kernel), new ListCommand(this.app, this.kernel)].forEach((e) => this.addCommand(e));
|
|
646
613
|
}
|
|
647
614
|
async loadDiscoveredCommands() {
|
|
648
615
|
const commands = [...this.app.registeredCommands.map((cmd) => new cmd(this.app, this.kernel))];
|
|
@@ -664,12 +631,31 @@ var Musket = class Musket {
|
|
|
664
631
|
this.commands.push(Signature.parseSignature(command.getSignature(), command));
|
|
665
632
|
}
|
|
666
633
|
initialize() {
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
|
|
634
|
+
/** Init the Musket Version */
|
|
635
|
+
const cliVersion = __h3ravel_shared.Logger.parse([["Musket CLI:", "white"], [this.kernel.consolePackage.version, "green"]], " ", false);
|
|
636
|
+
/** Init the App Version */
|
|
637
|
+
const localVersion = __h3ravel_shared.Logger.parse([["H3ravel Framework:", "white"], [this.kernel.modulePackage.version, "green"]], " ", false);
|
|
638
|
+
const additional = {
|
|
639
|
+
quiet: ["-q, --quiet", "Do not output any message"],
|
|
640
|
+
silent: ["--silent", "Do not output any message"],
|
|
641
|
+
verbose: ["-v, --verbose <number>", "Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug"],
|
|
642
|
+
lock: ["--lock", "Locked and loaded, do not ask any interactive question"]
|
|
643
|
+
};
|
|
644
|
+
/** Init Commander */
|
|
645
|
+
commander.program.name("musket").version(`${cliVersion}\n${localVersion}`).description(altLogo).addOption(new commander.Option(additional.quiet[0], additional.quiet[1]).implies({ silent: true })).addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).addOption(new commander.Option(additional.verbose[0], additional.verbose[1]).choices([
|
|
646
|
+
"1",
|
|
647
|
+
"2",
|
|
648
|
+
"3"
|
|
649
|
+
])).addOption(new commander.Option(additional.lock[0], additional.lock[1])).action(async () => {
|
|
650
|
+
const instance = new ListCommand(this.app, this.kernel);
|
|
651
|
+
instance.setInput(commander.program.opts(), commander.program.args, commander.program.registeredArguments, {}, commander.program);
|
|
652
|
+
instance.handle();
|
|
653
|
+
});
|
|
654
|
+
/** Create the init Command */
|
|
670
655
|
commander.program.command("init").description("Initialize H3ravel.").action(async () => {
|
|
671
|
-
|
|
656
|
+
__h3ravel_shared.Logger.success("Initialized: H3ravel has been initialized!");
|
|
672
657
|
});
|
|
658
|
+
/** Loop through all the available commands */
|
|
673
659
|
for (let i = 0; i < this.commands.length; i++) {
|
|
674
660
|
const command = this.commands[i];
|
|
675
661
|
const instance = command.commandClass;
|
|
@@ -677,8 +663,12 @@ var Musket = class Musket {
|
|
|
677
663
|
/**
|
|
678
664
|
* Initialize the base command
|
|
679
665
|
*/
|
|
680
|
-
const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").
|
|
681
|
-
|
|
666
|
+
const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").addOption(new commander.Option(additional.quiet[0], additional.quiet[1]).implies({ silent: true })).addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).addOption(new commander.Option(additional.verbose[0], additional.verbose[1]).choices([
|
|
667
|
+
"1",
|
|
668
|
+
"2",
|
|
669
|
+
"3"
|
|
670
|
+
])).addOption(new commander.Option(additional.lock[0], additional.lock[1])).action(async () => {
|
|
671
|
+
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
|
|
682
672
|
await instance.handle();
|
|
683
673
|
});
|
|
684
674
|
/**
|
|
@@ -691,8 +681,12 @@ var Musket = class Musket {
|
|
|
691
681
|
* Initialize the sub commands
|
|
692
682
|
*/
|
|
693
683
|
command.subCommands.filter((v, i$1, a) => !v.shared && a.findIndex((t) => t.name === v.name) === i$1).forEach((sub) => {
|
|
694
|
-
const cmd$1 = commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").
|
|
695
|
-
|
|
684
|
+
const cmd$1 = commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").addOption(new commander.Option(additional.quiet[0], additional.quiet[1]).implies({ silent: true })).addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).addOption(new commander.Option(additional.verbose[0], additional.verbose[1]).choices([
|
|
685
|
+
"1",
|
|
686
|
+
"2",
|
|
687
|
+
"3"
|
|
688
|
+
])).addOption(new commander.Option(additional.lock[0], additional.lock[1])).action(async () => {
|
|
689
|
+
instance.setInput(cmd$1.opts(), cmd$1.args, cmd$1.registeredArguments, sub, commander.program);
|
|
696
690
|
await instance.handle();
|
|
697
691
|
});
|
|
698
692
|
/**
|
|
@@ -723,11 +717,19 @@ var Musket = class Musket {
|
|
|
723
717
|
this.makeOption(opt, cmd, true);
|
|
724
718
|
});
|
|
725
719
|
cmd.action(async () => {
|
|
726
|
-
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
|
|
720
|
+
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
|
|
727
721
|
await instance.handle();
|
|
728
722
|
});
|
|
729
723
|
}
|
|
730
724
|
}
|
|
725
|
+
/** Rebuild the app on every command except fire so we wont need TS */
|
|
726
|
+
commander.program.hook("preAction", async (_, cmd) => {
|
|
727
|
+
if (cmd.name() !== "fire") await (0, tsdown.build)({
|
|
728
|
+
...TsdownConfig_default,
|
|
729
|
+
watch: false,
|
|
730
|
+
plugins: []
|
|
731
|
+
});
|
|
732
|
+
});
|
|
731
733
|
return commander.program;
|
|
732
734
|
}
|
|
733
735
|
makeOption(opt, cmd, parse, parent) {
|
|
@@ -746,15 +748,9 @@ var Musket = class Musket {
|
|
|
746
748
|
|
|
747
749
|
//#endregion
|
|
748
750
|
//#region src/Kernel.ts
|
|
749
|
-
var Kernel = class Kernel {
|
|
750
|
-
cwd;
|
|
751
|
-
output = __h3ravel_shared.Logger.log();
|
|
752
|
-
basePath = "";
|
|
753
|
-
modulePath;
|
|
754
|
-
consolePath;
|
|
755
|
-
modulePackage;
|
|
756
|
-
consolePackage;
|
|
751
|
+
var Kernel = class Kernel extends __h3ravel_core.ConsoleKernel {
|
|
757
752
|
constructor(app) {
|
|
753
|
+
super(app);
|
|
758
754
|
this.app = app;
|
|
759
755
|
}
|
|
760
756
|
static init(app) {
|
|
@@ -765,13 +761,10 @@ var Kernel = class Kernel {
|
|
|
765
761
|
await Musket.parse(this);
|
|
766
762
|
process.exit(0);
|
|
767
763
|
}
|
|
768
|
-
async ensureDirectoryExists(dir) {
|
|
769
|
-
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
770
|
-
}
|
|
771
764
|
async loadRequirements() {
|
|
772
765
|
this.cwd = node_path.default.join(process.cwd(), this.basePath);
|
|
773
|
-
this.modulePath =
|
|
774
|
-
this.consolePath =
|
|
766
|
+
this.modulePath = Helpers.findModulePkg("@h3ravel/core", this.cwd) ?? "";
|
|
767
|
+
this.consolePath = Helpers.findModulePkg("@h3ravel/console", this.cwd) ?? "";
|
|
775
768
|
try {
|
|
776
769
|
this.modulePackage = await import(node_path.default.join(this.modulePath, "package.json"));
|
|
777
770
|
} catch {
|
|
@@ -815,110 +808,17 @@ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
|
815
808
|
}
|
|
816
809
|
};
|
|
817
810
|
|
|
818
|
-
//#endregion
|
|
819
|
-
//#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0/node_modules/@rollup/plugin-run/dist/es/index.js
|
|
820
|
-
function run(opts = {}) {
|
|
821
|
-
let input;
|
|
822
|
-
let proc;
|
|
823
|
-
const args = opts.args || [];
|
|
824
|
-
const allowRestarts = opts.allowRestarts || false;
|
|
825
|
-
const overrideInput = opts.input;
|
|
826
|
-
const forkOptions = opts.options || opts;
|
|
827
|
-
delete forkOptions.args;
|
|
828
|
-
delete forkOptions.allowRestarts;
|
|
829
|
-
return {
|
|
830
|
-
name: "run",
|
|
831
|
-
buildStart(options) {
|
|
832
|
-
let inputs = overrideInput !== null && overrideInput !== void 0 ? overrideInput : options.input;
|
|
833
|
-
if (typeof inputs === "string") inputs = [inputs];
|
|
834
|
-
if (typeof inputs === "object") inputs = Object.values(inputs);
|
|
835
|
-
if (inputs.length > 1) throw new Error(`@rollup/plugin-run must have a single entry point; consider setting the \`input\` option`);
|
|
836
|
-
input = (0, path.resolve)(inputs[0]);
|
|
837
|
-
},
|
|
838
|
-
generateBundle(_outputOptions, _bundle, isWrite) {
|
|
839
|
-
if (!isWrite) this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`);
|
|
840
|
-
},
|
|
841
|
-
writeBundle(outputOptions, bundle) {
|
|
842
|
-
const forkBundle = (dir$1, entryFileName$1) => {
|
|
843
|
-
if (proc) proc.kill();
|
|
844
|
-
proc = (0, child_process.fork)((0, path.join)(dir$1, entryFileName$1), args, forkOptions);
|
|
845
|
-
};
|
|
846
|
-
const dir = outputOptions.dir || (0, path.dirname)(outputOptions.file);
|
|
847
|
-
const entryFileName = Object.keys(bundle).find((fileName) => {
|
|
848
|
-
const chunk = bundle[fileName];
|
|
849
|
-
return chunk.isEntry && chunk.facadeModuleId === input;
|
|
850
|
-
});
|
|
851
|
-
if (entryFileName) {
|
|
852
|
-
forkBundle(dir, entryFileName);
|
|
853
|
-
if (allowRestarts) {
|
|
854
|
-
process.stdin.resume();
|
|
855
|
-
process.stdin.setEncoding("utf8");
|
|
856
|
-
process.stdin.on("data", (data) => {
|
|
857
|
-
const line = data.toString().trim().toLowerCase();
|
|
858
|
-
if (line === "rs" || line === "restart" || data.toString().charCodeAt(0) === 11) forkBundle(dir, entryFileName);
|
|
859
|
-
else if (line === "cls" || line === "clear" || data.toString().charCodeAt(0) === 12) console.clear();
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
} else this.error(`@rollup/plugin-run could not find output chunk`);
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
//#endregion
|
|
868
|
-
//#region src/TsdownConfig.ts
|
|
869
|
-
const env = process.env.NODE_ENV || "development";
|
|
870
|
-
const outDir = env === "development" ? ".h3ravel/serve" : "dist";
|
|
871
|
-
const TsDownConfig = {
|
|
872
|
-
outDir,
|
|
873
|
-
entry: ["src/**/*.ts"],
|
|
874
|
-
format: ["esm"],
|
|
875
|
-
target: "node22",
|
|
876
|
-
sourcemap: env === "development",
|
|
877
|
-
clean: true,
|
|
878
|
-
shims: true,
|
|
879
|
-
copy: [
|
|
880
|
-
{
|
|
881
|
-
from: "public",
|
|
882
|
-
to: outDir
|
|
883
|
-
},
|
|
884
|
-
"src/resources",
|
|
885
|
-
"src/database"
|
|
886
|
-
],
|
|
887
|
-
env: env === "development" ? {
|
|
888
|
-
NODE_ENV: env,
|
|
889
|
-
SRC_PATH: outDir
|
|
890
|
-
} : {},
|
|
891
|
-
watch: env === "development" && process.env.CLI_BUILD !== "true" ? [
|
|
892
|
-
".env",
|
|
893
|
-
".env.*",
|
|
894
|
-
"src",
|
|
895
|
-
"../../packages"
|
|
896
|
-
] : false,
|
|
897
|
-
dts: false,
|
|
898
|
-
logLevel: "silent",
|
|
899
|
-
nodeProtocol: true,
|
|
900
|
-
skipNodeModulesBundle: true,
|
|
901
|
-
plugins: env === "development" && process.env.CLI_BUILD !== "true" ? [run({
|
|
902
|
-
env: Object.assign({}, process.env, {
|
|
903
|
-
NODE_ENV: env,
|
|
904
|
-
SRC_PATH: outDir
|
|
905
|
-
}),
|
|
906
|
-
execArgv: ["-r", "source-map-support/register"],
|
|
907
|
-
allowRestarts: false,
|
|
908
|
-
input: process.cwd() + "/src/server.ts"
|
|
909
|
-
})] : []
|
|
910
|
-
};
|
|
911
|
-
|
|
912
811
|
//#endregion
|
|
913
812
|
exports.Command = Command;
|
|
914
813
|
exports.ConsoleServiceProvider = ConsoleServiceProvider;
|
|
915
|
-
exports.FireCommand = FireCommand;
|
|
916
814
|
exports.Kernel = Kernel;
|
|
815
|
+
exports.ListCommand = ListCommand;
|
|
917
816
|
exports.MakeCommand = MakeCommand;
|
|
918
|
-
exports.MigrateCommand = MigrateCommand;
|
|
919
817
|
exports.Musket = Musket;
|
|
920
818
|
exports.Signature = Signature;
|
|
921
819
|
exports.TableGuesser = require_Utils.TableGuesser;
|
|
922
820
|
exports.TsDownConfig = TsDownConfig;
|
|
923
821
|
exports.Utils = require_Utils.Utils;
|
|
822
|
+
exports.altLogo = altLogo;
|
|
823
|
+
exports.logo = logo;
|
|
924
824
|
//# sourceMappingURL=index.cjs.map
|