@h3ravel/console 11.0.7 → 11.1.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 +2 -0
- package/bin/fire.js +2 -0
- package/dist/Utils-7OrjoB1C.d.cts +22 -0
- package/dist/Utils-B1kpj9-1.cjs +130 -0
- package/dist/Utils-B1kpj9-1.cjs.map +1 -0
- package/dist/Utils-DAJvoXlr.js +86 -0
- package/dist/Utils-DAJvoXlr.js.map +1 -0
- package/dist/Utils-DxnHOGMz.d.ts +22 -0
- package/dist/Utils.cjs +3 -217
- package/dist/Utils.d.cts +2 -0
- package/dist/Utils.d.ts +2 -0
- package/dist/Utils.js +3 -9
- package/dist/index.cjs +885 -933
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +270 -290
- package/dist/index.d.ts +270 -290
- package/dist/index.js +899 -44
- package/dist/index.js.map +1 -0
- package/package.json +35 -23
- package/bin/chunk-6Z5DP356.js +0 -1
- package/bin/lexer-DQCqS3nf-XQPNMZG6.js +0 -4
- package/bin/run.cjs +0 -26
- package/bin/run.js +0 -26
- package/dist/Commands/Command.cjs +0 -104
- package/dist/Commands/Command.js +0 -7
- package/dist/Commands/MakeCommand.cjs +0 -433
- package/dist/Commands/MakeCommand.js +0 -9
- package/dist/Commands/MigrateCommand.cjs +0 -200
- package/dist/Commands/MigrateCommand.js +0 -8
- package/dist/Commands/ServeCommand.cjs +0 -159
- package/dist/Commands/ServeCommand.js +0 -8
- package/dist/Contracts/ICommand.cjs +0 -18
- package/dist/Contracts/ICommand.js +0 -1
- package/dist/IO/app.cjs +0 -946
- package/dist/IO/app.js +0 -17
- package/dist/IO/providers.cjs +0 -930
- package/dist/IO/providers.js +0 -16
- package/dist/Kernel.cjs +0 -890
- package/dist/Kernel.js +0 -14
- package/dist/Musket.cjs +0 -835
- package/dist/Musket.js +0 -13
- package/dist/Providers/ConsoleServiceProvider.cjs +0 -912
- package/dist/Providers/ConsoleServiceProvider.js +0 -15
- package/dist/Signature.cjs +0 -172
- package/dist/Signature.js +0 -7
- package/dist/chunk-23QH5R54.js +0 -27
- package/dist/chunk-2O2AYFAG.js +0 -63
- package/dist/chunk-3ASEWMRX.js +0 -37
- package/dist/chunk-3FVPHQCH.js +0 -151
- package/dist/chunk-3RX6CLNR.js +0 -32
- package/dist/chunk-3VCNSA6P.js +0 -14
- package/dist/chunk-3WHUADTN.js +0 -6
- package/dist/chunk-6OCHCPBP.js +0 -36
- package/dist/chunk-6OIH6FS4.js +0 -32
- package/dist/chunk-7EWRZPTX.js +0 -63
- package/dist/chunk-7PUQ5ZIN.js +0 -6
- package/dist/chunk-A5AONVOH.js +0 -6
- package/dist/chunk-ADIVRUAJ.js +0 -27
- package/dist/chunk-CCEWV2BR.js +0 -39
- package/dist/chunk-CTQ6DUT2.js +0 -8
- package/dist/chunk-DXQTBFGG.js +0 -31
- package/dist/chunk-E4SSLXFT.js +0 -63
- package/dist/chunk-E5XIGIEX.js +0 -14
- package/dist/chunk-EIOQKTRM.js +0 -104
- package/dist/chunk-FOSDCKCR.js +0 -106
- package/dist/chunk-G4OE26TZ.js +0 -33
- package/dist/chunk-GVGO5OAK.js +0 -8
- package/dist/chunk-GXRCTWKL.js +0 -16
- package/dist/chunk-HVKW7JK4.js +0 -8
- package/dist/chunk-IGEFNODG.js +0 -22
- package/dist/chunk-JXL4VJHZ.js +0 -36
- package/dist/chunk-K3GOQSS3.js +0 -6
- package/dist/chunk-KCJKQP37.js +0 -133
- package/dist/chunk-KMIFCLXG.js +0 -16
- package/dist/chunk-KZA3MC77.js +0 -151
- package/dist/chunk-LLL3V7LB.js +0 -6
- package/dist/chunk-LQ6DL2HS.js +0 -68
- package/dist/chunk-M4ZRDJJ2.js +0 -68
- package/dist/chunk-MAQAT3PU.js +0 -32
- package/dist/chunk-MPXPSSLJ.js +0 -133
- package/dist/chunk-NADN2PHB.js +0 -0
- package/dist/chunk-NFRXMBRP.js +0 -24
- package/dist/chunk-NVPKTRMT.js +0 -7
- package/dist/chunk-O45AB4MX.js +0 -83
- package/dist/chunk-ORPRWIQ2.js +0 -33
- package/dist/chunk-P7M5PEDY.js +0 -18
- package/dist/chunk-PBNCVQZC.js +0 -6
- package/dist/chunk-PMV4TMFS.js +0 -151
- package/dist/chunk-POF4JGTX.js +0 -186
- package/dist/chunk-PYSJMSNM.js +0 -27
- package/dist/chunk-Q3OMG6YH.js +0 -186
- package/dist/chunk-QCNBVSFO.js +0 -68
- package/dist/chunk-QMEO4OUR.js +0 -151
- package/dist/chunk-QSQNELZQ.js +0 -83
- package/dist/chunk-RRP7K5LI.js +0 -36
- package/dist/chunk-SHUYVCID.js +0 -6
- package/dist/chunk-SP4JKAUC.js +0 -63
- package/dist/chunk-T6OOKENF.js +0 -6
- package/dist/chunk-TBDROT3I.js +0 -6356
- package/dist/chunk-TH2RWMWA.js +0 -133
- package/dist/chunk-TJZCDDEV.js +0 -36
- package/dist/chunk-TN5SV7LF.js +0 -133
- package/dist/chunk-U6TOLKGJ.js +0 -22
- package/dist/chunk-UCOXL3OM.js +0 -0
- package/dist/chunk-URLTFJET.js +0 -68
- package/dist/chunk-UWCTG2LX.js +0 -24
- package/dist/chunk-WO2BXMBQ.js +0 -6
- package/dist/chunk-XAWZUZVP.js +0 -32
- package/dist/chunk-XCOSZXAE.js +0 -133
- package/dist/chunk-XD2Q7LWE.js +0 -24
- package/dist/chunk-XSL373TG.js +0 -36
- package/dist/chunk-XUYTJO6X.js +0 -104
- package/dist/chunk-YAYU7VOK.js +0 -8
- package/dist/chunk-YRUCICBV.js +0 -24
- package/dist/chunk-Z5XE72Q5.js +0 -68
- package/dist/chunk-ZTIO25VB.js +0 -8
- package/dist/lexer-DQCqS3nf-6W2BHF4T.js +0 -68
- package/dist/run.cjs +0 -943
- package/dist/run.js +0 -14
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/Commands/MakeCommand.ts
|
|
32
|
-
var MakeCommand_exports = {};
|
|
33
|
-
__export(MakeCommand_exports, {
|
|
34
|
-
MakeCommand: () => MakeCommand
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(MakeCommand_exports);
|
|
37
|
-
|
|
38
|
-
// src/Utils.ts
|
|
39
|
-
var import_promises = require("fs/promises");
|
|
40
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
41
|
-
|
|
42
|
-
// ../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs
|
|
43
|
-
var import_path = require("path");
|
|
44
|
-
var import_fs = require("fs");
|
|
45
|
-
function sync_default(start, callback) {
|
|
46
|
-
let dir = (0, import_path.resolve)(".", start);
|
|
47
|
-
let tmp, stats = (0, import_fs.statSync)(dir);
|
|
48
|
-
if (!stats.isDirectory()) {
|
|
49
|
-
dir = (0, import_path.dirname)(dir);
|
|
50
|
-
}
|
|
51
|
-
while (true) {
|
|
52
|
-
tmp = callback(dir, (0, import_fs.readdirSync)(dir));
|
|
53
|
-
if (tmp) return (0, import_path.resolve)(dir, tmp);
|
|
54
|
-
dir = (0, import_path.dirname)(tmp = dir);
|
|
55
|
-
if (tmp === dir) break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
__name(sync_default, "default");
|
|
59
|
-
|
|
60
|
-
// src/Utils.ts
|
|
61
|
-
var import_path2 = __toESM(require("path"), 1);
|
|
62
|
-
var join = import_path2.default.join;
|
|
63
|
-
var Utils = class {
|
|
64
|
-
static {
|
|
65
|
-
__name(this, "Utils");
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Wraps text with chalk
|
|
69
|
-
*
|
|
70
|
-
* @param txt
|
|
71
|
-
* @param color
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
static textFormat(txt, color) {
|
|
75
|
-
return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Ouput formater object
|
|
79
|
-
*
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
static output() {
|
|
83
|
-
return {
|
|
84
|
-
success: /* @__PURE__ */ __name((msg, exit = false) => {
|
|
85
|
-
console.log(import_chalk.default.green("\u2713"), this.textFormat(msg, import_chalk.default.bgGreen), "\n");
|
|
86
|
-
if (exit) process.exit(0);
|
|
87
|
-
}, "success"),
|
|
88
|
-
info: /* @__PURE__ */ __name((msg, exit = false) => {
|
|
89
|
-
console.log(import_chalk.default.blue("\u2139"), this.textFormat(msg, import_chalk.default.bgBlue), "\n");
|
|
90
|
-
if (exit) process.exit(0);
|
|
91
|
-
}, "info"),
|
|
92
|
-
error: /* @__PURE__ */ __name((msg, exit = true) => {
|
|
93
|
-
if (msg instanceof Error) {
|
|
94
|
-
if (msg.message) {
|
|
95
|
-
console.error(import_chalk.default.red("\u2716"), this.textFormat("ERROR:" + msg.message, import_chalk.default.bgRed));
|
|
96
|
-
}
|
|
97
|
-
console.error(import_chalk.default.red(`${msg.detail ? `${msg.detail}
|
|
98
|
-
` : ""}${msg.stack}`), "\n");
|
|
99
|
-
} else {
|
|
100
|
-
console.error(import_chalk.default.red("\u2716"), this.textFormat(msg, import_chalk.default.bgRed), "\n");
|
|
101
|
-
}
|
|
102
|
-
if (exit) process.exit(1);
|
|
103
|
-
}, "error"),
|
|
104
|
-
split: /* @__PURE__ */ __name((name, value, status, exit = false) => {
|
|
105
|
-
status ??= "info";
|
|
106
|
-
const color = {
|
|
107
|
-
success: import_chalk.default.bgGreen,
|
|
108
|
-
info: import_chalk.default.bgBlue,
|
|
109
|
-
error: import_chalk.default.bgRed
|
|
110
|
-
};
|
|
111
|
-
const regex = /\x1b\[\d+m/g;
|
|
112
|
-
const width = Math.min(process.stdout.columns, 100);
|
|
113
|
-
const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
|
|
114
|
-
console.log(this.textFormat(name, color[status]), import_chalk.default.gray(".".repeat(dots)), value);
|
|
115
|
-
if (exit) process.exit(0);
|
|
116
|
-
}, "split"),
|
|
117
|
-
quiet: /* @__PURE__ */ __name(() => {
|
|
118
|
-
process.exit(0);
|
|
119
|
-
}, "quiet")
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
static findModulePkg(moduleId, cwd) {
|
|
123
|
-
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
124
|
-
let packageName = "";
|
|
125
|
-
if (parts.length > 0 && parts[0][0] === "@") {
|
|
126
|
-
packageName += parts.shift() + "/";
|
|
127
|
-
}
|
|
128
|
-
packageName += parts.shift();
|
|
129
|
-
const packageJson = import_path2.default.join(cwd ?? process.cwd(), "node_modules", packageName);
|
|
130
|
-
const resolved = this.findUpConfig(packageJson, "package", [
|
|
131
|
-
"json"
|
|
132
|
-
]);
|
|
133
|
-
if (!resolved) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
return import_path2.default.join(import_path2.default.dirname(resolved), parts.join("/"));
|
|
137
|
-
}
|
|
138
|
-
static async getMigrationPaths(cwd, migrator, defaultPath, path2) {
|
|
139
|
-
if (path2) {
|
|
140
|
-
return [
|
|
141
|
-
join(cwd, path2)
|
|
142
|
-
];
|
|
143
|
-
}
|
|
144
|
-
return [
|
|
145
|
-
...migrator.getPaths(),
|
|
146
|
-
join(cwd, defaultPath)
|
|
147
|
-
];
|
|
148
|
-
}
|
|
149
|
-
static twoColumnDetail(name, value) {
|
|
150
|
-
const regex = /\x1b\[\d+m/g;
|
|
151
|
-
const width = Math.min(process.stdout.columns, 100);
|
|
152
|
-
const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
|
|
153
|
-
return console.log(name, import_chalk.default.gray(".".repeat(dots)), value);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Check if file exists
|
|
157
|
-
*
|
|
158
|
-
* @param path
|
|
159
|
-
* @returns
|
|
160
|
-
*/
|
|
161
|
-
static async fileExists(path2) {
|
|
162
|
-
try {
|
|
163
|
-
await (0, import_promises.access)(path2);
|
|
164
|
-
return true;
|
|
165
|
-
} catch {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
static findUpConfig(cwd, name, extensions) {
|
|
170
|
-
return sync_default(cwd, (_dir, names) => {
|
|
171
|
-
for (const ext of extensions) {
|
|
172
|
-
const filename = `${name}.${ext}`;
|
|
173
|
-
if (names.includes(filename)) {
|
|
174
|
-
return filename;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return false;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var TableGuesser = class TableGuesser2 {
|
|
182
|
-
static {
|
|
183
|
-
__name(this, "TableGuesser");
|
|
184
|
-
}
|
|
185
|
-
static CREATE_PATTERNS = [
|
|
186
|
-
/^create_(\w+)_table$/,
|
|
187
|
-
/^create_(\w+)$/
|
|
188
|
-
];
|
|
189
|
-
static CHANGE_PATTERNS = [
|
|
190
|
-
/.+_(to|from|in)_(\w+)_table$/,
|
|
191
|
-
/.+_(to|from|in)_(\w+)$/
|
|
192
|
-
];
|
|
193
|
-
static guess(migration) {
|
|
194
|
-
for (const pattern of TableGuesser2.CREATE_PATTERNS) {
|
|
195
|
-
const matches = migration.match(pattern);
|
|
196
|
-
if (matches) {
|
|
197
|
-
return [
|
|
198
|
-
matches[1],
|
|
199
|
-
true
|
|
200
|
-
];
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
for (const pattern of TableGuesser2.CHANGE_PATTERNS) {
|
|
204
|
-
const matches = migration.match(pattern);
|
|
205
|
-
if (matches) {
|
|
206
|
-
return [
|
|
207
|
-
matches[2],
|
|
208
|
-
false
|
|
209
|
-
];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return [];
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// src/Commands/MakeCommand.ts
|
|
217
|
-
var import_promises2 = require("fs/promises");
|
|
218
|
-
|
|
219
|
-
// src/Commands/Command.ts
|
|
220
|
-
var Command = class {
|
|
221
|
-
static {
|
|
222
|
-
__name(this, "Command");
|
|
223
|
-
}
|
|
224
|
-
app;
|
|
225
|
-
kernel;
|
|
226
|
-
constructor(app, kernel) {
|
|
227
|
-
this.app = app;
|
|
228
|
-
this.kernel = kernel;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* The name and signature of the console command.
|
|
232
|
-
*
|
|
233
|
-
* @var string
|
|
234
|
-
*/
|
|
235
|
-
signature;
|
|
236
|
-
/**
|
|
237
|
-
* A dictionary of signatures or what not.
|
|
238
|
-
*
|
|
239
|
-
* @var object
|
|
240
|
-
*/
|
|
241
|
-
dictionary = {};
|
|
242
|
-
/**
|
|
243
|
-
* The console command description.
|
|
244
|
-
*
|
|
245
|
-
* @var string
|
|
246
|
-
*/
|
|
247
|
-
description;
|
|
248
|
-
/**
|
|
249
|
-
* The console command input.
|
|
250
|
-
*
|
|
251
|
-
* @var object
|
|
252
|
-
*/
|
|
253
|
-
input = {
|
|
254
|
-
options: {},
|
|
255
|
-
arguments: {}
|
|
256
|
-
};
|
|
257
|
-
/**
|
|
258
|
-
* Execute the console command.
|
|
259
|
-
*/
|
|
260
|
-
async handle(..._args) {
|
|
261
|
-
}
|
|
262
|
-
setApplication(app) {
|
|
263
|
-
this.app = app;
|
|
264
|
-
}
|
|
265
|
-
setInput(options, args, regArgs, dictionary) {
|
|
266
|
-
this.dictionary = dictionary;
|
|
267
|
-
this.input.options = options;
|
|
268
|
-
this.input.arguments = regArgs.map((e, i) => ({
|
|
269
|
-
[e.name()]: args[i]
|
|
270
|
-
})).reduce((e, x) => Object.assign(e, x), {});
|
|
271
|
-
}
|
|
272
|
-
getSignature() {
|
|
273
|
-
return this.signature;
|
|
274
|
-
}
|
|
275
|
-
getDescription() {
|
|
276
|
-
return this.description;
|
|
277
|
-
}
|
|
278
|
-
option(key, def) {
|
|
279
|
-
return this.input.options[key] ?? def;
|
|
280
|
-
}
|
|
281
|
-
options(key) {
|
|
282
|
-
if (key) {
|
|
283
|
-
return this.input.options[key];
|
|
284
|
-
}
|
|
285
|
-
return this.input.options;
|
|
286
|
-
}
|
|
287
|
-
argument(key, def) {
|
|
288
|
-
return this.input.arguments[key] ?? def;
|
|
289
|
-
}
|
|
290
|
-
arguments() {
|
|
291
|
-
return this.input.arguments;
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// src/Commands/MakeCommand.ts
|
|
296
|
-
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
297
|
-
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
298
|
-
var import_node_fs = require("fs");
|
|
299
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
300
|
-
var MakeCommand = class extends Command {
|
|
301
|
-
static {
|
|
302
|
-
__name(this, "MakeCommand");
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* The name and signature of the console command.
|
|
306
|
-
*
|
|
307
|
-
* @var string
|
|
308
|
-
*/
|
|
309
|
-
signature = `#make:
|
|
310
|
-
{controller : Generates a new controller class. | {--a|api : Generate an API resource controller} | {--force : Overide existing controller.} }
|
|
311
|
-
{resource : Generates a new API resource class.}
|
|
312
|
-
{migration : Generates a new database migration class. | {--l|type=ts : The file type to generate} | {--t|table : The table to migrate} | {--c|create : The table to be created} }
|
|
313
|
-
{factory : Generates a new database factory class.}
|
|
314
|
-
{seeder : Generates a new database seeder class.}
|
|
315
|
-
{model : Generates a new Arquebus model class. | {--t|type=ts : The file type to generate}}
|
|
316
|
-
{^name : The name of the [name] to generate}
|
|
317
|
-
`;
|
|
318
|
-
/**
|
|
319
|
-
* The console command description.
|
|
320
|
-
*
|
|
321
|
-
* @var string
|
|
322
|
-
*/
|
|
323
|
-
description = "Generate component classes";
|
|
324
|
-
async handle() {
|
|
325
|
-
const command = this.dictionary.baseCommand;
|
|
326
|
-
const methods = {
|
|
327
|
-
controller: "makeController",
|
|
328
|
-
resource: "makeResource",
|
|
329
|
-
migration: "makeMigration",
|
|
330
|
-
factory: "makeFactory",
|
|
331
|
-
seeder: "makeSeeder",
|
|
332
|
-
model: "makeModel"
|
|
333
|
-
};
|
|
334
|
-
try {
|
|
335
|
-
await this?.[methods[command]]();
|
|
336
|
-
} catch (e) {
|
|
337
|
-
this.kernel.output.error(e);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Generate a new controller class.
|
|
342
|
-
*/
|
|
343
|
-
async makeController() {
|
|
344
|
-
const type = this.option("api") ? "-resource" : "";
|
|
345
|
-
const name = this.argument("name");
|
|
346
|
-
const force = this.option("force");
|
|
347
|
-
const path2 = import_node_path.default.join(app_path("Http/Controllers"), name + ".ts");
|
|
348
|
-
const dbPath = Utils.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
|
|
349
|
-
const stubPath = import_node_path.default.join(dbPath, `dist/stubs/controller${type}.stub`);
|
|
350
|
-
if (!force && (0, import_node_fs.existsSync)(path2)) {
|
|
351
|
-
this.kernel.output.error(`ERORR: ${name} controller already exists`);
|
|
352
|
-
}
|
|
353
|
-
let stub = await (0, import_promises2.readFile)(stubPath, "utf-8");
|
|
354
|
-
stub = stub.replace(/{{ name }}/g, name);
|
|
355
|
-
await (0, import_promises2.writeFile)(path2, stub);
|
|
356
|
-
this.kernel.output.split(`INFO: Controller Created`, import_chalk2.default.gray(import_node_path.default.basename(path2)));
|
|
357
|
-
}
|
|
358
|
-
makeResource() {
|
|
359
|
-
this.kernel.output.success(`Resource support is not yet available`);
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Generate a new database migration class
|
|
363
|
-
*/
|
|
364
|
-
async makeMigration() {
|
|
365
|
-
const name = this.argument("name");
|
|
366
|
-
const datePrefix = (0, import_dayjs.default)().format("YYYY_MM_DD_HHmmss");
|
|
367
|
-
const path2 = import_node_path.default.join(database_path("migrations"), `${datePrefix}_${name}.ts`);
|
|
368
|
-
const dbPath = Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
369
|
-
let create = this.option("create", false);
|
|
370
|
-
let table = this.option("table");
|
|
371
|
-
if (!table && typeof create === "string") {
|
|
372
|
-
table = create;
|
|
373
|
-
create = true;
|
|
374
|
-
}
|
|
375
|
-
if (!table) {
|
|
376
|
-
const guessed = TableGuesser.guess(name);
|
|
377
|
-
table = guessed[0];
|
|
378
|
-
create = !!guessed[1];
|
|
379
|
-
}
|
|
380
|
-
const stubPath = import_node_path.default.join(dbPath, this.getMigrationStubName(table, create));
|
|
381
|
-
let stub = await (0, import_promises2.readFile)(stubPath, "utf-8");
|
|
382
|
-
if (table !== null) {
|
|
383
|
-
stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
384
|
-
}
|
|
385
|
-
this.kernel.output.info("INFO: Creating Migration");
|
|
386
|
-
await this.kernel.ensureDirectoryExists(import_node_path.default.dirname(path2));
|
|
387
|
-
await (0, import_promises2.writeFile)(path2, stub);
|
|
388
|
-
this.kernel.output.split(`INFO: Migration Created`, import_chalk2.default.gray(import_node_path.default.basename(path2)));
|
|
389
|
-
}
|
|
390
|
-
makeFactory() {
|
|
391
|
-
this.kernel.output.success(`Factory support is not yet available`);
|
|
392
|
-
}
|
|
393
|
-
makeSeeder() {
|
|
394
|
-
this.kernel.output.success(`Seeder support is not yet available`);
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Generate a new Arquebus model class
|
|
398
|
-
*/
|
|
399
|
-
async makeModel() {
|
|
400
|
-
const type = this.option("type", "ts");
|
|
401
|
-
const name = this.argument("name");
|
|
402
|
-
const path2 = import_node_path.default.join(app_path("Models"), name.toLowerCase() + "." + type);
|
|
403
|
-
const dbPath = Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
404
|
-
const stubPath = import_node_path.default.join(dbPath, `dist/stubs/model-${type}.stub`);
|
|
405
|
-
let stub = await (0, import_promises2.readFile)(stubPath, "utf-8");
|
|
406
|
-
stub = stub.replace(/{{ name }}/g, name);
|
|
407
|
-
await (0, import_promises2.writeFile)(path2, stub);
|
|
408
|
-
this.kernel.output.split(`INFO: Model Created`, import_chalk2.default.gray(import_node_path.default.basename(path2)));
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Ge the database migration file name
|
|
412
|
-
*
|
|
413
|
-
* @param table
|
|
414
|
-
* @param create
|
|
415
|
-
* @param type
|
|
416
|
-
* @returns
|
|
417
|
-
*/
|
|
418
|
-
getMigrationStubName(table, create = false, type = "ts") {
|
|
419
|
-
let stub;
|
|
420
|
-
if (!table) {
|
|
421
|
-
stub = `migration-${type}.stub`;
|
|
422
|
-
} else if (create) {
|
|
423
|
-
stub = `migration.create-${type}.stub`;
|
|
424
|
-
} else {
|
|
425
|
-
stub = `migration.update-${type}.stub`;
|
|
426
|
-
}
|
|
427
|
-
return "dist/stubs/" + stub;
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
431
|
-
0 && (module.exports = {
|
|
432
|
-
MakeCommand
|
|
433
|
-
});
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/Commands/MigrateCommand.ts
|
|
22
|
-
var MigrateCommand_exports = {};
|
|
23
|
-
__export(MigrateCommand_exports, {
|
|
24
|
-
MigrateCommand: () => MigrateCommand
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(MigrateCommand_exports);
|
|
27
|
-
|
|
28
|
-
// src/Commands/Command.ts
|
|
29
|
-
var Command = class {
|
|
30
|
-
static {
|
|
31
|
-
__name(this, "Command");
|
|
32
|
-
}
|
|
33
|
-
app;
|
|
34
|
-
kernel;
|
|
35
|
-
constructor(app, kernel) {
|
|
36
|
-
this.app = app;
|
|
37
|
-
this.kernel = kernel;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The name and signature of the console command.
|
|
41
|
-
*
|
|
42
|
-
* @var string
|
|
43
|
-
*/
|
|
44
|
-
signature;
|
|
45
|
-
/**
|
|
46
|
-
* A dictionary of signatures or what not.
|
|
47
|
-
*
|
|
48
|
-
* @var object
|
|
49
|
-
*/
|
|
50
|
-
dictionary = {};
|
|
51
|
-
/**
|
|
52
|
-
* The console command description.
|
|
53
|
-
*
|
|
54
|
-
* @var string
|
|
55
|
-
*/
|
|
56
|
-
description;
|
|
57
|
-
/**
|
|
58
|
-
* The console command input.
|
|
59
|
-
*
|
|
60
|
-
* @var object
|
|
61
|
-
*/
|
|
62
|
-
input = {
|
|
63
|
-
options: {},
|
|
64
|
-
arguments: {}
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Execute the console command.
|
|
68
|
-
*/
|
|
69
|
-
async handle(..._args) {
|
|
70
|
-
}
|
|
71
|
-
setApplication(app) {
|
|
72
|
-
this.app = app;
|
|
73
|
-
}
|
|
74
|
-
setInput(options, args, regArgs, dictionary) {
|
|
75
|
-
this.dictionary = dictionary;
|
|
76
|
-
this.input.options = options;
|
|
77
|
-
this.input.arguments = regArgs.map((e, i) => ({
|
|
78
|
-
[e.name()]: args[i]
|
|
79
|
-
})).reduce((e, x) => Object.assign(e, x), {});
|
|
80
|
-
}
|
|
81
|
-
getSignature() {
|
|
82
|
-
return this.signature;
|
|
83
|
-
}
|
|
84
|
-
getDescription() {
|
|
85
|
-
return this.description;
|
|
86
|
-
}
|
|
87
|
-
option(key, def) {
|
|
88
|
-
return this.input.options[key] ?? def;
|
|
89
|
-
}
|
|
90
|
-
options(key) {
|
|
91
|
-
if (key) {
|
|
92
|
-
return this.input.options[key];
|
|
93
|
-
}
|
|
94
|
-
return this.input.options;
|
|
95
|
-
}
|
|
96
|
-
argument(key, def) {
|
|
97
|
-
return this.input.arguments[key] ?? def;
|
|
98
|
-
}
|
|
99
|
-
arguments() {
|
|
100
|
-
return this.input.arguments;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/Commands/MigrateCommand.ts
|
|
105
|
-
var MigrateCommand = class extends Command {
|
|
106
|
-
static {
|
|
107
|
-
__name(this, "MigrateCommand");
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* The name and signature of the console command.
|
|
111
|
-
*
|
|
112
|
-
* @var string
|
|
113
|
-
*/
|
|
114
|
-
signature = `migrate:
|
|
115
|
-
{fresh : Drop all tables and re-run all migrations.}
|
|
116
|
-
{install : Create the migration repository.}
|
|
117
|
-
{refresh : Reset and re-run all migrations.}
|
|
118
|
-
{reset : Rollback all database migrations.}
|
|
119
|
-
{rollback : Rollback the last database migration.}
|
|
120
|
-
{status : Show the status of each migration.}
|
|
121
|
-
{publish : Publish any migration files from installed packages.}
|
|
122
|
-
{^--s|seed : Seed the database}
|
|
123
|
-
`;
|
|
124
|
-
/**
|
|
125
|
-
* The console command description.
|
|
126
|
-
*
|
|
127
|
-
* @var string
|
|
128
|
-
*/
|
|
129
|
-
description = "Run all pending migrations.";
|
|
130
|
-
/**
|
|
131
|
-
* Execute the console command.
|
|
132
|
-
*/
|
|
133
|
-
async handle() {
|
|
134
|
-
const command = this.dictionary.name ?? this.dictionary.baseCommand;
|
|
135
|
-
const methods = {
|
|
136
|
-
migrate: "migrateRun",
|
|
137
|
-
fresh: "migrateFresh",
|
|
138
|
-
install: "migrateInstall",
|
|
139
|
-
refresh: "migrateRefresh",
|
|
140
|
-
reset: "migrateReset",
|
|
141
|
-
rollback: "migrateRollback",
|
|
142
|
-
status: "migrateStatus",
|
|
143
|
-
publish: "migratePublish"
|
|
144
|
-
};
|
|
145
|
-
await this?.[methods[command]]();
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Run all pending migrations.
|
|
149
|
-
*/
|
|
150
|
-
async migrateRun() {
|
|
151
|
-
this.kernel.output.success(`Running migrations are not yet supported.`);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Drop all tables and re-run all migrations.
|
|
155
|
-
*/
|
|
156
|
-
async migrateFresh() {
|
|
157
|
-
this.kernel.output.success(`Drop all tables and re-run all migrations.`);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Create the migration repository.
|
|
161
|
-
*/
|
|
162
|
-
async migrateInstall() {
|
|
163
|
-
this.kernel.output.success(`Create the migration repository.`);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Reset and re-run all migrations.
|
|
167
|
-
*/
|
|
168
|
-
async migrateRefresh() {
|
|
169
|
-
this.kernel.output.success(`Resetting and re-running migrations is not yet supported.`);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Rollback all database migrations.
|
|
173
|
-
*/
|
|
174
|
-
async migrateReset() {
|
|
175
|
-
this.kernel.output.success(`Rolling back all migration is not yet supported.`);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Rollback the last database migration.
|
|
179
|
-
*/
|
|
180
|
-
async migrateRollback() {
|
|
181
|
-
this.kernel.output.success(`Rolling back the last migration is not yet supported.`);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Show the status of each migration.
|
|
185
|
-
*/
|
|
186
|
-
async migrateStatus() {
|
|
187
|
-
const path = app_path();
|
|
188
|
-
this.kernel.output.success(`Show the status of each migration.`);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Publish any migration files from installed packages.
|
|
192
|
-
*/
|
|
193
|
-
async migratePublish() {
|
|
194
|
-
this.kernel.output.success(`Publish any migration files from installed packages.`);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
198
|
-
0 && (module.exports = {
|
|
199
|
-
MigrateCommand
|
|
200
|
-
});
|