@h3ravel/console 11.1.0 → 11.2.0
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 +1 -1
- package/bin/fire.js +1 -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 +324 -435
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -133
- package/dist/index.d.ts +31 -133
- package/dist/index.js +319 -429
- 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,164 @@
|
|
|
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
20
|
require("@h3ravel/console");
|
|
25
21
|
require("@h3ravel/http");
|
|
26
22
|
require("@h3ravel/router");
|
|
23
|
+
require("@h3ravel/database");
|
|
27
24
|
require("@h3ravel/cache");
|
|
28
25
|
require("@h3ravel/queue");
|
|
29
26
|
require("@h3ravel/mail");
|
|
30
27
|
require("@h3ravel/config");
|
|
31
|
-
let __h3ravel_shared = require("@h3ravel/shared");
|
|
32
|
-
__h3ravel_shared = require_Utils.__toESM(__h3ravel_shared);
|
|
33
28
|
let commander = require("commander");
|
|
34
29
|
commander = require_Utils.__toESM(commander);
|
|
35
30
|
let child_process = require("child_process");
|
|
36
31
|
child_process = require_Utils.__toESM(child_process);
|
|
32
|
+
let tsdown = require("tsdown");
|
|
33
|
+
tsdown = require_Utils.__toESM(tsdown);
|
|
37
34
|
|
|
38
35
|
//#region src/Commands/Command.ts
|
|
39
|
-
var Command = class {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
var Command = class extends __h3ravel_core.ConsoleCommand {};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/logo.ts
|
|
40
|
+
const logo = String.raw`
|
|
41
|
+
111
|
|
42
|
+
111111111
|
|
43
|
+
1111111111 111111
|
|
44
|
+
111111 111 111111
|
|
45
|
+
111111 111 111111
|
|
46
|
+
11111 111 11111
|
|
47
|
+
1111111 111 1111111
|
|
48
|
+
111 11111 111 111111 111 1111 1111 11111111 1111
|
|
49
|
+
111 11111 1111 111111 111 1111 1111 1111 11111 1111
|
|
50
|
+
111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
|
|
51
|
+
111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
|
|
52
|
+
111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
|
|
53
|
+
111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
|
|
54
|
+
111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
|
|
55
|
+
1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
|
|
56
|
+
11011 111111 11 11111
|
|
57
|
+
111111 11101 111111
|
|
58
|
+
111111 111 111111
|
|
59
|
+
111111 111 111111
|
|
60
|
+
111111111
|
|
61
|
+
110
|
|
62
|
+
`;
|
|
63
|
+
const altLogo = String.raw`
|
|
64
|
+
_ _ _____ _
|
|
65
|
+
| | | |___ / _ __ __ ___ _____| |
|
|
66
|
+
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
67
|
+
| _ |___) | | | (_| |\ V / __/ |
|
|
68
|
+
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
69
|
+
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/Commands/ListCommand.ts
|
|
74
|
+
var ListCommand = class extends Command {
|
|
44
75
|
/**
|
|
45
76
|
* The name and signature of the console command.
|
|
46
77
|
*
|
|
47
78
|
* @var string
|
|
48
79
|
*/
|
|
49
|
-
signature;
|
|
50
|
-
/**
|
|
51
|
-
* A dictionary of signatures or what not.
|
|
52
|
-
*
|
|
53
|
-
* @var object
|
|
54
|
-
*/
|
|
55
|
-
dictionary = {};
|
|
80
|
+
signature = "list";
|
|
56
81
|
/**
|
|
57
82
|
* The console command description.
|
|
58
83
|
*
|
|
59
84
|
* @var string
|
|
60
85
|
*/
|
|
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;
|
|
86
|
+
description = "List all available commands";
|
|
87
|
+
async handle() {
|
|
88
|
+
const options = [{
|
|
89
|
+
short: "-h",
|
|
90
|
+
long: "--help",
|
|
91
|
+
description: "Display help for the given command. When no command is given display help for the list command"
|
|
92
|
+
}].concat(this.program.options).map((e) => {
|
|
93
|
+
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("");
|
|
94
|
+
});
|
|
95
|
+
const grouped = this.program.commands.map((e) => {
|
|
96
|
+
return __h3ravel_shared.Logger.describe(__h3ravel_shared.Logger.log(" " + e.name(), "green", false), e.description(), 25, false).join("");
|
|
97
|
+
}).reduce((acc, cmd) => {
|
|
98
|
+
/** strip colors before checking prefix */
|
|
99
|
+
const clean = cmd.replace(/\x1b\[\d+m/g, "");
|
|
100
|
+
const prefix = clean.includes(":") ? clean.split(":")[0].trim() : "__root__";
|
|
101
|
+
acc[prefix] ??= [];
|
|
102
|
+
/** keep original with colors */
|
|
103
|
+
acc[prefix].push(cmd);
|
|
104
|
+
return acc;
|
|
105
|
+
}, {});
|
|
106
|
+
const list = Object.entries(grouped).map(([group, cmds]) => {
|
|
107
|
+
const label = group === "__root__" ? "" : group;
|
|
108
|
+
return [__h3ravel_shared.Logger.log(label, "yellow", false), cmds.join("\n")].join("\n");
|
|
109
|
+
});
|
|
110
|
+
/** Ootput the app version */
|
|
111
|
+
__h3ravel_shared.Logger.log([["H3ravel Framework", "white"], [this.kernel.modulePackage.version, "green"]], " ");
|
|
112
|
+
console.log("");
|
|
113
|
+
console.log(altLogo);
|
|
114
|
+
console.log("");
|
|
115
|
+
__h3ravel_shared.Logger.log("Usage:", "yellow");
|
|
116
|
+
__h3ravel_shared.Logger.log(" command [options] [arguments]", "white");
|
|
117
|
+
console.log("");
|
|
118
|
+
/** Ootput the options */
|
|
119
|
+
__h3ravel_shared.Logger.log("Options:", "yellow");
|
|
120
|
+
console.log(options.join("\n").trim());
|
|
121
|
+
console.log("");
|
|
122
|
+
/** Ootput the commands */
|
|
123
|
+
__h3ravel_shared.Logger.log("Available Commands:", "yellow");
|
|
124
|
+
console.log(list.join("\n\n").trim());
|
|
101
125
|
}
|
|
102
126
|
};
|
|
103
127
|
|
|
104
128
|
//#endregion
|
|
105
|
-
//#region
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`;
|
|
129
|
+
//#region ../filesystem/dist/index.js
|
|
130
|
+
var Helpers = class {
|
|
131
|
+
static findModulePkg(moduleId, cwd) {
|
|
132
|
+
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
133
|
+
let packageName = "";
|
|
134
|
+
if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
|
|
135
|
+
packageName += parts.shift();
|
|
136
|
+
const packageJson = path.default.join(cwd ?? process.cwd(), "node_modules", packageName);
|
|
137
|
+
const resolved = this.findUpConfig(packageJson, "package", ["json"]);
|
|
138
|
+
if (!resolved) return;
|
|
139
|
+
return path.default.join(path.default.dirname(resolved), parts.join("/"));
|
|
140
|
+
}
|
|
118
141
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* @
|
|
142
|
+
* Check if file exists
|
|
143
|
+
*
|
|
144
|
+
* @param path
|
|
145
|
+
* @returns
|
|
122
146
|
*/
|
|
123
|
-
|
|
124
|
-
async handle() {
|
|
147
|
+
static async fileExists(path$1$1) {
|
|
125
148
|
try {
|
|
126
|
-
await
|
|
127
|
-
|
|
128
|
-
|
|
149
|
+
await (0, fs_promises.access)(path$1$1);
|
|
150
|
+
return true;
|
|
151
|
+
} catch {
|
|
152
|
+
return false;
|
|
129
153
|
}
|
|
130
154
|
}
|
|
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)
|
|
155
|
+
static findUpConfig(cwd, name, extensions) {
|
|
156
|
+
return require_Utils.sync_default(cwd, (_dir, names) => {
|
|
157
|
+
for (const ext of extensions) {
|
|
158
|
+
const filename = `${name}.${ext}`;
|
|
159
|
+
if (names.includes(filename)) return filename;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
158
162
|
});
|
|
159
163
|
}
|
|
160
164
|
};
|
|
@@ -168,12 +172,37 @@ var MakeCommand = class extends Command {
|
|
|
168
172
|
* @var string
|
|
169
173
|
*/
|
|
170
174
|
signature = `#make:
|
|
171
|
-
{controller :
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
{controller : Create a new controller class.
|
|
176
|
+
| {--a|api : Exclude the create and edit methods from the controller}
|
|
177
|
+
| {--m|model= : Generate a resource controller for the given model}
|
|
178
|
+
| {--r|resource : Generate a resource controller class}
|
|
179
|
+
| {--force : Create the controller even if it already exists}
|
|
180
|
+
}
|
|
181
|
+
{resource : Create a new resource.
|
|
182
|
+
| {--c|collection : Create a resource collection}
|
|
183
|
+
| {--force : Create the resource even if it already exists}
|
|
184
|
+
}
|
|
185
|
+
{migration : Generates a new database migration class.
|
|
186
|
+
| {--l|type=ts : The file type to generate}
|
|
187
|
+
| {--t|table : The table to migrate}
|
|
188
|
+
| {--c|create : The table to be created}
|
|
189
|
+
}
|
|
190
|
+
{factory : Create a new model factory.}
|
|
191
|
+
{seeder : Create a new seeder class.}
|
|
192
|
+
{view : Create a new view.
|
|
193
|
+
| {--force : Create the view even if it already exists}
|
|
194
|
+
}
|
|
195
|
+
{model : Create a new Eloquent model class.
|
|
196
|
+
| {--api : Indicates if the generated controller should be an API resource controller}
|
|
197
|
+
| {--c|controller : Create a new controller for the model}
|
|
198
|
+
| {--f|factory : Create a new factory for the model}
|
|
199
|
+
| {--m|migration : Create a new migration file for the model}
|
|
200
|
+
| {--r|resource : Indicates if the generated controller should be a resource controller}
|
|
201
|
+
| {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
|
|
202
|
+
| {--s|seed : Create a new seeder for the model}
|
|
203
|
+
| {--t|type=ts : The file type to generate}
|
|
204
|
+
| {--force : Create the model even if it already exists}
|
|
205
|
+
}
|
|
177
206
|
{^name : The name of the [name] to generate}
|
|
178
207
|
`;
|
|
179
208
|
/**
|
|
@@ -183,39 +212,41 @@ var MakeCommand = class extends Command {
|
|
|
183
212
|
*/
|
|
184
213
|
description = "Generate component classes";
|
|
185
214
|
async handle() {
|
|
186
|
-
const command = this.dictionary.baseCommand;
|
|
215
|
+
const command = this.dictionary.baseCommand ?? this.dictionary.name;
|
|
187
216
|
const methods = {
|
|
188
217
|
controller: "makeController",
|
|
189
218
|
resource: "makeResource",
|
|
190
219
|
migration: "makeMigration",
|
|
191
220
|
factory: "makeFactory",
|
|
192
221
|
seeder: "makeSeeder",
|
|
193
|
-
model: "makeModel"
|
|
222
|
+
model: "makeModel",
|
|
223
|
+
view: "makeView"
|
|
194
224
|
};
|
|
195
225
|
try {
|
|
196
226
|
await this?.[methods[command]]();
|
|
197
227
|
} catch (e) {
|
|
198
|
-
|
|
228
|
+
__h3ravel_shared.Logger.error(e);
|
|
199
229
|
}
|
|
200
230
|
}
|
|
201
231
|
/**
|
|
202
|
-
*
|
|
232
|
+
* Create a new controller class.
|
|
203
233
|
*/
|
|
204
234
|
async makeController() {
|
|
205
235
|
const type = this.option("api") ? "-resource" : "";
|
|
206
236
|
const name = this.argument("name");
|
|
207
237
|
const force = this.option("force");
|
|
208
238
|
const path$5 = node_path.default.join(app_path("Http/Controllers"), name + ".ts");
|
|
209
|
-
const crtlrPath =
|
|
239
|
+
const crtlrPath = Helpers.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
|
|
210
240
|
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
|
|
211
|
-
|
|
241
|
+
/** Check if the controller already exists */
|
|
242
|
+
if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
|
|
212
243
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
213
244
|
stub = stub.replace(/{{ name }}/g, name);
|
|
214
245
|
await (0, node_fs_promises.writeFile)(path$5, stub);
|
|
215
|
-
|
|
246
|
+
__h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
|
|
216
247
|
}
|
|
217
248
|
makeResource() {
|
|
218
|
-
|
|
249
|
+
__h3ravel_shared.Logger.success("Resource support is not yet available");
|
|
219
250
|
}
|
|
220
251
|
/**
|
|
221
252
|
* Generate a new database migration class
|
|
@@ -239,16 +270,22 @@ var MakeCommand = class extends Command {
|
|
|
239
270
|
const stubPath = node_path.default.join(crtlrPath, this.getMigrationStubName(table, create));
|
|
240
271
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
241
272
|
if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
242
|
-
|
|
273
|
+
__h3ravel_shared.Logger.info("INFO: Creating Migration");
|
|
243
274
|
await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$5));
|
|
244
275
|
await (0, node_fs_promises.writeFile)(path$5, stub);
|
|
245
|
-
|
|
276
|
+
__h3ravel_shared.Logger.split("INFO: Migration Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
|
|
246
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Create a new model factory
|
|
280
|
+
*/
|
|
247
281
|
makeFactory() {
|
|
248
|
-
|
|
282
|
+
__h3ravel_shared.Logger.success("Factory support is not yet available");
|
|
249
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Create a new seeder class
|
|
286
|
+
*/
|
|
250
287
|
makeSeeder() {
|
|
251
|
-
|
|
288
|
+
__h3ravel_shared.Logger.success("Seeder support is not yet available");
|
|
252
289
|
}
|
|
253
290
|
/**
|
|
254
291
|
* Generate a new Arquebus model class
|
|
@@ -256,13 +293,29 @@ var MakeCommand = class extends Command {
|
|
|
256
293
|
async makeModel() {
|
|
257
294
|
const type = this.option("type", "ts");
|
|
258
295
|
const name = this.argument("name");
|
|
259
|
-
const
|
|
296
|
+
const force = this.argument("force");
|
|
297
|
+
const path$5 = node_path.default.join(app_path("Models"), name.toLowerCase(), "." + type);
|
|
298
|
+
/** Check if the model already exists */
|
|
299
|
+
if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
|
|
260
300
|
const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
261
301
|
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/model-${type}.stub`);
|
|
262
302
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
263
303
|
stub = stub.replace(/{{ name }}/g, name);
|
|
264
304
|
await (0, node_fs_promises.writeFile)(path$5, stub);
|
|
265
|
-
|
|
305
|
+
__h3ravel_shared.Logger.split("INFO: Model Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Create a new view.
|
|
309
|
+
*/
|
|
310
|
+
async makeView() {
|
|
311
|
+
const name = this.argument("name");
|
|
312
|
+
const force = this.option("force");
|
|
313
|
+
const path$5 = node_path.default.join(base_path("src/resources/views"), name + ".edge");
|
|
314
|
+
if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$5, "/"), { recursive: true });
|
|
315
|
+
/** Check if the view already exists */
|
|
316
|
+
if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
|
|
317
|
+
await (0, node_fs_promises.writeFile)(path$5, `{{-- src/resources/views/${name}.edge --}}`);
|
|
318
|
+
__h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
|
|
266
319
|
}
|
|
267
320
|
/**
|
|
268
321
|
* Ge the database migration file name
|
|
@@ -281,181 +334,6 @@ var MakeCommand = class extends Command {
|
|
|
281
334
|
}
|
|
282
335
|
};
|
|
283
336
|
|
|
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
337
|
//#endregion
|
|
460
338
|
//#region src/Signature.ts
|
|
461
339
|
var Signature = class Signature {
|
|
@@ -620,13 +498,107 @@ var Signature = class Signature {
|
|
|
620
498
|
}
|
|
621
499
|
};
|
|
622
500
|
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0/node_modules/@rollup/plugin-run/dist/es/index.js
|
|
503
|
+
function run(opts = {}) {
|
|
504
|
+
let input;
|
|
505
|
+
let proc;
|
|
506
|
+
const args = opts.args || [];
|
|
507
|
+
const allowRestarts = opts.allowRestarts || false;
|
|
508
|
+
const overrideInput = opts.input;
|
|
509
|
+
const forkOptions = opts.options || opts;
|
|
510
|
+
delete forkOptions.args;
|
|
511
|
+
delete forkOptions.allowRestarts;
|
|
512
|
+
return {
|
|
513
|
+
name: "run",
|
|
514
|
+
buildStart(options) {
|
|
515
|
+
let inputs = overrideInput !== null && overrideInput !== void 0 ? overrideInput : options.input;
|
|
516
|
+
if (typeof inputs === "string") inputs = [inputs];
|
|
517
|
+
if (typeof inputs === "object") inputs = Object.values(inputs);
|
|
518
|
+
if (inputs.length > 1) throw new Error(`@rollup/plugin-run must have a single entry point; consider setting the \`input\` option`);
|
|
519
|
+
input = (0, path.resolve)(inputs[0]);
|
|
520
|
+
},
|
|
521
|
+
generateBundle(_outputOptions, _bundle, isWrite) {
|
|
522
|
+
if (!isWrite) this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`);
|
|
523
|
+
},
|
|
524
|
+
writeBundle(outputOptions, bundle) {
|
|
525
|
+
const forkBundle = (dir$1, entryFileName$1) => {
|
|
526
|
+
if (proc) proc.kill();
|
|
527
|
+
proc = (0, child_process.fork)((0, path.join)(dir$1, entryFileName$1), args, forkOptions);
|
|
528
|
+
};
|
|
529
|
+
const dir = outputOptions.dir || (0, path.dirname)(outputOptions.file);
|
|
530
|
+
const entryFileName = Object.keys(bundle).find((fileName) => {
|
|
531
|
+
const chunk = bundle[fileName];
|
|
532
|
+
return chunk.isEntry && chunk.facadeModuleId === input;
|
|
533
|
+
});
|
|
534
|
+
if (entryFileName) {
|
|
535
|
+
forkBundle(dir, entryFileName);
|
|
536
|
+
if (allowRestarts) {
|
|
537
|
+
process.stdin.resume();
|
|
538
|
+
process.stdin.setEncoding("utf8");
|
|
539
|
+
process.stdin.on("data", (data) => {
|
|
540
|
+
const line = data.toString().trim().toLowerCase();
|
|
541
|
+
if (line === "rs" || line === "restart" || data.toString().charCodeAt(0) === 11) forkBundle(dir, entryFileName);
|
|
542
|
+
else if (line === "cls" || line === "clear" || data.toString().charCodeAt(0) === 12) console.clear();
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
} else this.error(`@rollup/plugin-run could not find output chunk`);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/TsdownConfig.ts
|
|
552
|
+
const env = process.env.NODE_ENV || "development";
|
|
553
|
+
const outDir = env === "development" ? ".h3ravel/serve" : "dist";
|
|
554
|
+
const TsDownConfig = {
|
|
555
|
+
outDir,
|
|
556
|
+
entry: ["src/**/*.ts"],
|
|
557
|
+
format: ["esm"],
|
|
558
|
+
target: "node22",
|
|
559
|
+
sourcemap: env === "development",
|
|
560
|
+
clean: true,
|
|
561
|
+
shims: true,
|
|
562
|
+
copy: [
|
|
563
|
+
{
|
|
564
|
+
from: "public",
|
|
565
|
+
to: outDir
|
|
566
|
+
},
|
|
567
|
+
"src/resources",
|
|
568
|
+
"src/database"
|
|
569
|
+
],
|
|
570
|
+
env: env === "development" ? {
|
|
571
|
+
NODE_ENV: env,
|
|
572
|
+
SRC_PATH: outDir
|
|
573
|
+
} : {},
|
|
574
|
+
watch: env === "development" && process.env.CLI_BUILD !== "true" ? [
|
|
575
|
+
".env",
|
|
576
|
+
".env.*",
|
|
577
|
+
"src",
|
|
578
|
+
"../../packages"
|
|
579
|
+
] : false,
|
|
580
|
+
dts: false,
|
|
581
|
+
logLevel: "silent",
|
|
582
|
+
nodeProtocol: true,
|
|
583
|
+
skipNodeModulesBundle: true,
|
|
584
|
+
plugins: env === "development" && process.env.CLI_BUILD !== "true" ? [run({
|
|
585
|
+
env: Object.assign({}, process.env, {
|
|
586
|
+
NODE_ENV: env,
|
|
587
|
+
SRC_PATH: outDir
|
|
588
|
+
}),
|
|
589
|
+
execArgv: ["-r", "source-map-support/register"],
|
|
590
|
+
allowRestarts: false,
|
|
591
|
+
input: process.cwd() + "/src/server.ts"
|
|
592
|
+
})] : []
|
|
593
|
+
};
|
|
594
|
+
var TsdownConfig_default = TsDownConfig;
|
|
595
|
+
|
|
623
596
|
//#endregion
|
|
624
597
|
//#region src/Musket.ts
|
|
625
598
|
/**
|
|
626
599
|
* Musket is H3ravel's CLI tool
|
|
627
600
|
*/
|
|
628
601
|
var Musket = class Musket {
|
|
629
|
-
output = __h3ravel_shared.Logger.log();
|
|
630
602
|
commands = [];
|
|
631
603
|
constructor(app, kernel) {
|
|
632
604
|
this.app = app;
|
|
@@ -638,11 +610,7 @@ var Musket = class Musket {
|
|
|
638
610
|
return this.initialize();
|
|
639
611
|
}
|
|
640
612
|
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));
|
|
613
|
+
[new MakeCommand(this.app, this.kernel), new ListCommand(this.app, this.kernel)].forEach((e) => this.addCommand(e));
|
|
646
614
|
}
|
|
647
615
|
async loadDiscoveredCommands() {
|
|
648
616
|
const commands = [...this.app.registeredCommands.map((cmd) => new cmd(this.app, this.kernel))];
|
|
@@ -664,12 +632,27 @@ var Musket = class Musket {
|
|
|
664
632
|
this.commands.push(Signature.parseSignature(command.getSignature(), command));
|
|
665
633
|
}
|
|
666
634
|
initialize() {
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
|
|
635
|
+
/** Init the Musket Version */
|
|
636
|
+
const cliVersion = __h3ravel_shared.Logger.parse([["Musket CLI:", "white"], [this.kernel.consolePackage.version, "green"]], " ", false);
|
|
637
|
+
/** Init the App Version */
|
|
638
|
+
const localVersion = __h3ravel_shared.Logger.parse([["H3ravel Framework:", "white"], [this.kernel.modulePackage.version, "green"]], " ", false);
|
|
639
|
+
const additional = {
|
|
640
|
+
quiet: ["-q, --quiet", "Do not output any message"],
|
|
641
|
+
silent: ["--silent", "Do not output any message"],
|
|
642
|
+
verbose: ["-v, --verbose <number>", "Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug"],
|
|
643
|
+
interaction: ["-n, --no-interaction", "Do not ask any interactive question"]
|
|
644
|
+
};
|
|
645
|
+
/** Init Commander */
|
|
646
|
+
commander.program.name("musket").version(`${cliVersion}\n${localVersion}`).addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]).description(altLogo).action(async () => {
|
|
647
|
+
const instance = new ListCommand(this.app, this.kernel);
|
|
648
|
+
instance.setInput(commander.program.opts(), commander.program.args, commander.program.registeredArguments, {}, commander.program);
|
|
649
|
+
instance.handle();
|
|
650
|
+
});
|
|
651
|
+
/** Create the init Command */
|
|
670
652
|
commander.program.command("init").description("Initialize H3ravel.").action(async () => {
|
|
671
|
-
|
|
653
|
+
__h3ravel_shared.Logger.success("Initialized: H3ravel has been initialized!");
|
|
672
654
|
});
|
|
655
|
+
/** Loop through all the available commands */
|
|
673
656
|
for (let i = 0; i < this.commands.length; i++) {
|
|
674
657
|
const command = this.commands[i];
|
|
675
658
|
const instance = command.commandClass;
|
|
@@ -677,8 +660,8 @@ var Musket = class Musket {
|
|
|
677
660
|
/**
|
|
678
661
|
* Initialize the base command
|
|
679
662
|
*/
|
|
680
|
-
const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").action(async () => {
|
|
681
|
-
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
|
|
663
|
+
const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]).action(async () => {
|
|
664
|
+
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
|
|
682
665
|
await instance.handle();
|
|
683
666
|
});
|
|
684
667
|
/**
|
|
@@ -691,8 +674,8 @@ var Musket = class Musket {
|
|
|
691
674
|
* Initialize the sub commands
|
|
692
675
|
*/
|
|
693
676
|
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 || "").action(async () => {
|
|
695
|
-
instance.setInput(cmd$1.opts(), cmd$1.args, cmd$1.registeredArguments, sub);
|
|
677
|
+
const cmd$1 = commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]).action(async () => {
|
|
678
|
+
instance.setInput(cmd$1.opts(), cmd$1.args, cmd$1.registeredArguments, sub, commander.program);
|
|
696
679
|
await instance.handle();
|
|
697
680
|
});
|
|
698
681
|
/**
|
|
@@ -718,16 +701,24 @@ var Musket = class Musket {
|
|
|
718
701
|
/**
|
|
719
702
|
* Initialize command with options
|
|
720
703
|
*/
|
|
721
|
-
const cmd = commander.program.command(command.baseCommand).description(command.description ?? "");
|
|
704
|
+
const cmd = commander.program.command(command.baseCommand).description(command.description ?? "").addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]);
|
|
722
705
|
command?.options?.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
|
|
723
706
|
this.makeOption(opt, cmd, true);
|
|
724
707
|
});
|
|
725
708
|
cmd.action(async () => {
|
|
726
|
-
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
|
|
709
|
+
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
|
|
727
710
|
await instance.handle();
|
|
728
711
|
});
|
|
729
712
|
}
|
|
730
713
|
}
|
|
714
|
+
/** Rebuild the app on every command except fire so we wont need TS */
|
|
715
|
+
commander.program.hook("preAction", async (_, cmd) => {
|
|
716
|
+
if (cmd.name() !== "fire") await (0, tsdown.build)({
|
|
717
|
+
...TsdownConfig_default,
|
|
718
|
+
watch: false,
|
|
719
|
+
plugins: []
|
|
720
|
+
});
|
|
721
|
+
});
|
|
731
722
|
return commander.program;
|
|
732
723
|
}
|
|
733
724
|
makeOption(opt, cmd, parse, parent) {
|
|
@@ -746,15 +737,9 @@ var Musket = class Musket {
|
|
|
746
737
|
|
|
747
738
|
//#endregion
|
|
748
739
|
//#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;
|
|
740
|
+
var Kernel = class Kernel extends __h3ravel_core.ConsoleKernel {
|
|
757
741
|
constructor(app) {
|
|
742
|
+
super(app);
|
|
758
743
|
this.app = app;
|
|
759
744
|
}
|
|
760
745
|
static init(app) {
|
|
@@ -765,13 +750,10 @@ var Kernel = class Kernel {
|
|
|
765
750
|
await Musket.parse(this);
|
|
766
751
|
process.exit(0);
|
|
767
752
|
}
|
|
768
|
-
async ensureDirectoryExists(dir) {
|
|
769
|
-
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
770
|
-
}
|
|
771
753
|
async loadRequirements() {
|
|
772
754
|
this.cwd = node_path.default.join(process.cwd(), this.basePath);
|
|
773
|
-
this.modulePath =
|
|
774
|
-
this.consolePath =
|
|
755
|
+
this.modulePath = Helpers.findModulePkg("@h3ravel/core", this.cwd) ?? "";
|
|
756
|
+
this.consolePath = Helpers.findModulePkg("@h3ravel/console", this.cwd) ?? "";
|
|
775
757
|
try {
|
|
776
758
|
this.modulePackage = await import(node_path.default.join(this.modulePath, "package.json"));
|
|
777
759
|
} catch {
|
|
@@ -815,110 +797,17 @@ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
|
815
797
|
}
|
|
816
798
|
};
|
|
817
799
|
|
|
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
800
|
//#endregion
|
|
913
801
|
exports.Command = Command;
|
|
914
802
|
exports.ConsoleServiceProvider = ConsoleServiceProvider;
|
|
915
|
-
exports.FireCommand = FireCommand;
|
|
916
803
|
exports.Kernel = Kernel;
|
|
804
|
+
exports.ListCommand = ListCommand;
|
|
917
805
|
exports.MakeCommand = MakeCommand;
|
|
918
|
-
exports.MigrateCommand = MigrateCommand;
|
|
919
806
|
exports.Musket = Musket;
|
|
920
807
|
exports.Signature = Signature;
|
|
921
808
|
exports.TableGuesser = require_Utils.TableGuesser;
|
|
922
809
|
exports.TsDownConfig = TsDownConfig;
|
|
923
810
|
exports.Utils = require_Utils.Utils;
|
|
811
|
+
exports.altLogo = altLogo;
|
|
812
|
+
exports.logo = logo;
|
|
924
813
|
//# sourceMappingURL=index.cjs.map
|