@h3ravel/console 11.10.1 → 11.11.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/dist/index.d.cts DELETED
@@ -1,127 +0,0 @@
1
- /// <reference path="./app.globals.d.ts" />
2
- import * as execa0 from "execa";
3
- import { Command } from "@h3ravel/musket";
4
- import { ServiceProvider } from "@h3ravel/core";
5
- import { Options } from "tsdown";
6
-
7
- //#region src/Commands/BuildCommand.d.ts
8
- declare class BuildCommand extends Command {
9
- /**
10
- * The name and signature of the console command.
11
- *
12
- * @var string
13
- */
14
- protected signature: string;
15
- /**
16
- * The console command description.
17
- *
18
- * @var string
19
- */
20
- protected description: string;
21
- handle(): Promise<void>;
22
- protected fire(): Promise<void>;
23
- /**
24
- * build
25
- */
26
- static build({
27
- debug,
28
- minify,
29
- mute,
30
- verbosity,
31
- outDir
32
- }?: {
33
- mute: boolean;
34
- debug: boolean;
35
- minify: boolean;
36
- verbosity: number;
37
- outDir: string;
38
- }): Promise<void | execa0.Result<{
39
- stdout: "inherit";
40
- stderr: "inherit";
41
- cwd: string;
42
- env: NodeJS.ProcessEnv & {
43
- EXTENDED_DEBUG: string;
44
- CLI_BUILD: string;
45
- NODE_ENV: string;
46
- DIST_DIR: string;
47
- DIST_MINIFY: boolean;
48
- LOG_LEVEL: string;
49
- };
50
- }>>;
51
- }
52
- //#endregion
53
- //#region src/Commands/MakeCommand.d.ts
54
- declare class MakeCommand extends Command {
55
- /**
56
- * The name and signature of the console command.
57
- *
58
- * @var string
59
- */
60
- protected signature: string;
61
- /**
62
- * The console command description.
63
- *
64
- * @var string
65
- */
66
- protected description: string;
67
- handle(this: any): Promise<void>;
68
- /**
69
- * Create a new controller class.
70
- */
71
- protected makeController(): Promise<void>;
72
- protected makeResource(): void;
73
- /**
74
- * Create a new Musket command
75
- */
76
- protected makeCommand(): void;
77
- /**
78
- * Create a new view.
79
- */
80
- protected makeView(): Promise<void>;
81
- }
82
- //#endregion
83
- //#region src/Commands/PostinstallCommand.d.ts
84
- declare class PostinstallCommand extends Command {
85
- /**
86
- * The name and signature of the console command.
87
- *
88
- * @var string
89
- */
90
- protected signature: string;
91
- /**
92
- * The console command description.
93
- *
94
- * @var string
95
- */
96
- protected description: string;
97
- handle(): Promise<void>;
98
- /**
99
- * Create sqlite database if none exist
100
- *
101
- * @returns
102
- */
103
- private createSqliteDB;
104
- }
105
- //#endregion
106
- //#region src/Providers/ConsoleServiceProvider.d.ts
107
- /**
108
- * Handles CLI commands and tooling.
109
- *
110
- * Auto-Registered when in CLI mode
111
- */
112
- declare class ConsoleServiceProvider extends ServiceProvider {
113
- static priority: number;
114
- /**
115
- * Indicate that this service provider only runs in console
116
- */
117
- static runsInConsole: boolean;
118
- runsInConsole: boolean;
119
- register(): void;
120
- boot(): void;
121
- }
122
- //#endregion
123
- //#region src/TsdownConfig.d.ts
124
- declare const TsDownConfig: Options;
125
- //#endregion
126
- export { BuildCommand, ConsoleServiceProvider, MakeCommand, PostinstallCommand, TsDownConfig };
127
- //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts DELETED
@@ -1,127 +0,0 @@
1
- /// <reference path="./app.globals.d.ts" />
2
- import { Command } from "@h3ravel/musket";
3
- import * as execa0 from "execa";
4
- import { ServiceProvider } from "@h3ravel/core";
5
- import { Options } from "tsdown";
6
-
7
- //#region src/Commands/BuildCommand.d.ts
8
- declare class BuildCommand extends Command {
9
- /**
10
- * The name and signature of the console command.
11
- *
12
- * @var string
13
- */
14
- protected signature: string;
15
- /**
16
- * The console command description.
17
- *
18
- * @var string
19
- */
20
- protected description: string;
21
- handle(): Promise<void>;
22
- protected fire(): Promise<void>;
23
- /**
24
- * build
25
- */
26
- static build({
27
- debug,
28
- minify,
29
- mute,
30
- verbosity,
31
- outDir
32
- }?: {
33
- mute: boolean;
34
- debug: boolean;
35
- minify: boolean;
36
- verbosity: number;
37
- outDir: string;
38
- }): Promise<void | execa0.Result<{
39
- stdout: "inherit";
40
- stderr: "inherit";
41
- cwd: string;
42
- env: NodeJS.ProcessEnv & {
43
- EXTENDED_DEBUG: string;
44
- CLI_BUILD: string;
45
- NODE_ENV: string;
46
- DIST_DIR: string;
47
- DIST_MINIFY: boolean;
48
- LOG_LEVEL: string;
49
- };
50
- }>>;
51
- }
52
- //#endregion
53
- //#region src/Commands/MakeCommand.d.ts
54
- declare class MakeCommand extends Command {
55
- /**
56
- * The name and signature of the console command.
57
- *
58
- * @var string
59
- */
60
- protected signature: string;
61
- /**
62
- * The console command description.
63
- *
64
- * @var string
65
- */
66
- protected description: string;
67
- handle(this: any): Promise<void>;
68
- /**
69
- * Create a new controller class.
70
- */
71
- protected makeController(): Promise<void>;
72
- protected makeResource(): void;
73
- /**
74
- * Create a new Musket command
75
- */
76
- protected makeCommand(): void;
77
- /**
78
- * Create a new view.
79
- */
80
- protected makeView(): Promise<void>;
81
- }
82
- //#endregion
83
- //#region src/Commands/PostinstallCommand.d.ts
84
- declare class PostinstallCommand extends Command {
85
- /**
86
- * The name and signature of the console command.
87
- *
88
- * @var string
89
- */
90
- protected signature: string;
91
- /**
92
- * The console command description.
93
- *
94
- * @var string
95
- */
96
- protected description: string;
97
- handle(): Promise<void>;
98
- /**
99
- * Create sqlite database if none exist
100
- *
101
- * @returns
102
- */
103
- private createSqliteDB;
104
- }
105
- //#endregion
106
- //#region src/Providers/ConsoleServiceProvider.d.ts
107
- /**
108
- * Handles CLI commands and tooling.
109
- *
110
- * Auto-Registered when in CLI mode
111
- */
112
- declare class ConsoleServiceProvider extends ServiceProvider {
113
- static priority: number;
114
- /**
115
- * Indicate that this service provider only runs in console
116
- */
117
- static runsInConsole: boolean;
118
- runsInConsole: boolean;
119
- register(): void;
120
- boot(): void;
121
- }
122
- //#endregion
123
- //#region src/TsdownConfig.d.ts
124
- declare const TsDownConfig: Options;
125
- //#endregion
126
- export { BuildCommand, ConsoleServiceProvider, MakeCommand, PostinstallCommand, TsDownConfig };
127
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js DELETED
@@ -1,415 +0,0 @@
1
- import { FileSystem, Logger, TaskManager } from "@h3ravel/shared";
2
- import { Command, Kernel } from "@h3ravel/musket";
3
- import { execa } from "execa";
4
- import preferredPM from "preferred-pm";
5
- import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
6
- import { Str } from "@h3ravel/support";
7
- import nodepath from "node:path";
8
- import { ContainerResolver, ServiceProvider } from "@h3ravel/core";
9
- import { existsSync } from "node:fs";
10
- import { fork } from "child_process";
11
- import { dirname, join, resolve } from "path";
12
-
13
- //#region src/Commands/BuildCommand.ts
14
- var BuildCommand = class BuildCommand extends Command {
15
- /**
16
- * The name and signature of the console command.
17
- *
18
- * @var string
19
- */
20
- signature = `build
21
- {--m|minify : Minify your bundle output}
22
- {--d|dev : Build for dev but don't watch for changes}
23
- `;
24
- /**
25
- * The console command description.
26
- *
27
- * @var string
28
- */
29
- description = "Build the app for production";
30
- async handle() {
31
- try {
32
- await this.fire();
33
- } catch (e) {
34
- Logger.error(e);
35
- }
36
- }
37
- async fire() {
38
- const outDir$1 = this.option("dev") ? ".h3ravel/serve" : env("DIST_DIR", "dist");
39
- const minify = this.option("minify");
40
- const verbosity = this.getVerbosity();
41
- const debug = verbosity > 0;
42
- this.newLine();
43
- await BuildCommand.build({
44
- outDir: outDir$1,
45
- minify,
46
- verbosity,
47
- debug,
48
- mute: false
49
- });
50
- this.newLine();
51
- }
52
- /**
53
- * build
54
- */
55
- static async build({ debug, minify, mute, verbosity, outDir: outDir$1 } = {
56
- mute: false,
57
- debug: false,
58
- minify: false,
59
- verbosity: 0,
60
- outDir: "dist"
61
- }) {
62
- const pm = (await preferredPM(base_path()))?.name ?? "pnpm";
63
- const ENV_VARS = {
64
- EXTENDED_DEBUG: debug ? "true" : "false",
65
- CLI_BUILD: "true",
66
- NODE_ENV: "production",
67
- DIST_DIR: outDir$1,
68
- DIST_MINIFY: minify,
69
- LOG_LEVEL: [
70
- "silent",
71
- "info",
72
- "warn",
73
- "error"
74
- ][verbosity]
75
- };
76
- const silent = ENV_VARS.LOG_LEVEL === "silent" ? "--silent" : null;
77
- if (mute) return await execa(pm, [
78
- "tsdown",
79
- silent,
80
- "--config-loader",
81
- "unconfig",
82
- "-c",
83
- "tsdown.default.config.ts"
84
- ].filter((e) => e !== null), {
85
- stdout: "inherit",
86
- stderr: "inherit",
87
- cwd: base_path(),
88
- env: Object.assign({}, process.env, ENV_VARS)
89
- });
90
- const type = outDir$1 === "dist" ? "Production" : "Development";
91
- return await TaskManager.advancedTaskRunner([[`Creating ${type} Bundle`, "STARTED"], [`${type} Bundle Created`, "COMPLETED"]], async () => {
92
- await execa(pm, [
93
- "tsdown",
94
- silent,
95
- "--config-loader",
96
- "unconfig",
97
- "-c",
98
- "tsdown.default.config.ts"
99
- ].filter((e) => e !== null), {
100
- stdout: "inherit",
101
- stderr: "inherit",
102
- cwd: base_path(),
103
- env: Object.assign({}, process.env, ENV_VARS)
104
- });
105
- });
106
- }
107
- };
108
-
109
- //#endregion
110
- //#region src/Commands/MakeCommand.ts
111
- var MakeCommand = class extends Command {
112
- /**
113
- * The name and signature of the console command.
114
- *
115
- * @var string
116
- */
117
- signature = `#make:
118
- {controller : Create a new controller class.
119
- | {--a|api : Exclude the create and edit methods from the controller}
120
- | {--m|model= : Generate a resource controller for the given model}
121
- | {--r|resource : Generate a resource controller class}
122
- | {--force : Create the controller even if it already exists}
123
- }
124
- {resource : Create a new resource.
125
- | {--c|collection : Create a resource collection}
126
- | {--force : Create the resource even if it already exists}
127
- }
128
- {command : Create a new Musket command.
129
- | {--command : The terminal command that will be used to invoke the class}
130
- | {--force : Create the class even if the console command already exists}
131
- }
132
- {view : Create a new view.
133
- | {--force : Create the view even if it already exists}
134
- }
135
- {^name : The name of the [name] to generate}
136
- `;
137
- /**
138
- * The console command description.
139
- *
140
- * @var string
141
- */
142
- description = "Generate component classes";
143
- async handle() {
144
- const command = this.dictionary.baseCommand ?? this.dictionary.name;
145
- if (!this.argument("name")) this.program.error("Please provide a valid name for the " + command);
146
- await this[{
147
- controller: "makeController",
148
- resource: "makeResource",
149
- view: "makeView",
150
- command: "makeCommand"
151
- }[command]]();
152
- }
153
- /**
154
- * Create a new controller class.
155
- */
156
- async makeController() {
157
- const type = this.option("api") ? "-resource" : "";
158
- const name = this.argument("name");
159
- const force = this.option("force");
160
- const crtlrPath = FileSystem.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
161
- const stubPath = nodepath.join(crtlrPath, `dist/stubs/controller${type}.stub`);
162
- const path = app_path(`Http/Controllers/${name}.ts`);
163
- /** The Controller is scoped to a path make sure to create the associated directories */
164
- if (name.includes("/")) await mkdir(Str.beforeLast(path, "/"), { recursive: true });
165
- /** Check if the controller already exists */
166
- if (!force && await FileSystem.fileExists(path)) Logger.error(`ERORR: ${name} controller already exists`);
167
- let stub = await readFile(stubPath, "utf-8");
168
- stub = stub.replace(/{{ name }}/g, name);
169
- await writeFile(path, stub);
170
- Logger.split("INFO: Controller Created", Logger.log(nodepath.basename(path), "gray", false));
171
- }
172
- makeResource() {
173
- Logger.success("Resource support is not yet available");
174
- }
175
- /**
176
- * Create a new Musket command
177
- */
178
- makeCommand() {
179
- Logger.success("Musket command creation is not yet available");
180
- }
181
- /**
182
- * Create a new view.
183
- */
184
- async makeView() {
185
- const name = this.argument("name");
186
- const force = this.option("force");
187
- const path = base_path(`src/resources/views/${name}.edge`);
188
- /** The view is scoped to a path make sure to create the associated directories */
189
- if (name.includes("/")) await mkdir(Str.beforeLast(path, "/"), { recursive: true });
190
- /** Check if the view already exists */
191
- if (!force && await FileSystem.fileExists(path)) Logger.error(`ERORR: ${name} view already exists`);
192
- await writeFile(path, `{{-- src/resources/views/${name}.edge --}}`);
193
- Logger.split("INFO: View Created", Logger.log(`src/resources/views/${name}.edge`, "gray", false));
194
- }
195
- };
196
-
197
- //#endregion
198
- //#region src/Commands/PostinstallCommand.ts
199
- var PostinstallCommand = class extends Command {
200
- /**
201
- * The name and signature of the console command.
202
- *
203
- * @var string
204
- */
205
- signature = "postinstall";
206
- /**
207
- * The console command description.
208
- *
209
- * @var string
210
- */
211
- description = "Default post installation command";
212
- async handle() {
213
- this.createSqliteDB();
214
- }
215
- /**
216
- * Create sqlite database if none exist
217
- *
218
- * @returns
219
- */
220
- async createSqliteDB() {
221
- if (config("database.default") !== "sqlite") return;
222
- if (!await FileSystem.fileExists(database_path())) await mkdir(database_path(), { recursive: true });
223
- if (!await FileSystem.fileExists(database_path("db.sqlite"))) await writeFile(database_path("db.sqlite"), "");
224
- }
225
- };
226
-
227
- //#endregion
228
- //#region src/logo.ts
229
- const logo = String.raw`
230
- 111
231
- 111111111
232
- 1111111111 111111
233
- 111111 111 111111
234
- 111111 111 111111
235
- 11111 111 11111
236
- 1111111 111 1111111
237
- 111 11111 111 111111 111 1111 1111 11111111 1111
238
- 111 11111 1111 111111 111 1111 1111 1111 11111 1111
239
- 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
240
- 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
241
- 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
242
- 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
243
- 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
244
- 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
245
- 11011 111111 11 11111
246
- 111111 11101 111111
247
- 111111 111 111111
248
- 111111 111 111111
249
- 111111111
250
- 110
251
- `;
252
- const altLogo = String.raw`
253
- _ _ _____ _
254
- | | | |___ / _ __ __ ___ _____| |
255
- | |_| | |_ \| '__/ _ \ \ / / _ \ |
256
- | _ |___) | | | (_| |\ V / __/ |
257
- |_| |_|____/|_| \__,_| \_/ \___|_|
258
-
259
- `;
260
-
261
- //#endregion
262
- //#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0_rollup@4.52.3/node_modules/@rollup/plugin-run/dist/es/index.js
263
- function run(opts = {}) {
264
- let input;
265
- let proc;
266
- const args = opts.args || [];
267
- const allowRestarts = opts.allowRestarts || false;
268
- const overrideInput = opts.input;
269
- const forkOptions = opts.options || opts;
270
- delete forkOptions.args;
271
- delete forkOptions.allowRestarts;
272
- return {
273
- name: "run",
274
- buildStart(options) {
275
- let inputs = overrideInput !== null && overrideInput !== void 0 ? overrideInput : options.input;
276
- if (typeof inputs === "string") inputs = [inputs];
277
- if (typeof inputs === "object") inputs = Object.values(inputs);
278
- if (inputs.length > 1) throw new Error(`@rollup/plugin-run must have a single entry point; consider setting the \`input\` option`);
279
- input = resolve(inputs[0]);
280
- },
281
- generateBundle(_outputOptions, _bundle, isWrite) {
282
- if (!isWrite) this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`);
283
- },
284
- writeBundle(outputOptions, bundle) {
285
- const forkBundle = (dir$1, entryFileName$1) => {
286
- if (proc) proc.kill();
287
- proc = fork(join(dir$1, entryFileName$1), args, forkOptions);
288
- };
289
- const dir = outputOptions.dir || dirname(outputOptions.file);
290
- const entryFileName = Object.keys(bundle).find((fileName) => {
291
- const chunk = bundle[fileName];
292
- return chunk.isEntry && chunk.facadeModuleId === input;
293
- });
294
- if (entryFileName) {
295
- forkBundle(dir, entryFileName);
296
- if (allowRestarts) {
297
- process.stdin.resume();
298
- process.stdin.setEncoding("utf8");
299
- process.stdin.on("data", (data) => {
300
- const line = data.toString().trim().toLowerCase();
301
- if (line === "rs" || line === "restart" || data.toString().charCodeAt(0) === 11) forkBundle(dir, entryFileName);
302
- else if (line === "cls" || line === "clear" || data.toString().charCodeAt(0) === 12) console.clear();
303
- });
304
- }
305
- } else this.error(`@rollup/plugin-run could not find output chunk`);
306
- }
307
- };
308
- }
309
-
310
- //#endregion
311
- //#region src/TsdownConfig.ts
312
- const env$1 = process.env.NODE_ENV || "development";
313
- let outDir = env$1 === "development" ? ".h3ravel/serve" : "dist";
314
- if (process.env.DIST_DIR) outDir = process.env.DIST_DIR;
315
- const TsDownConfig = {
316
- outDir,
317
- entry: ["src/**/*.ts"],
318
- format: ["esm"],
319
- target: "node22",
320
- sourcemap: env$1 === "development",
321
- minify: !!process.env.DIST_MINIFY,
322
- external: [/^@h3ravel\/.*/gi],
323
- clean: true,
324
- shims: true,
325
- copy: [
326
- {
327
- from: "public",
328
- to: outDir
329
- },
330
- "src/resources",
331
- "src/database"
332
- ],
333
- env: env$1 === "development" ? {
334
- NODE_ENV: env$1,
335
- DIST_DIR: outDir
336
- } : {},
337
- watch: env$1 === "development" && process.env.CLI_BUILD !== "true" ? [
338
- ".env",
339
- ".env.*",
340
- "src",
341
- "../../packages"
342
- ] : false,
343
- dts: false,
344
- logLevel: "silent",
345
- nodeProtocol: true,
346
- skipNodeModulesBundle: true,
347
- hooks(e) {
348
- e.hook("build:done", async () => {
349
- const paths = [
350
- "database/migrations",
351
- "database/factories",
352
- "database/seeders"
353
- ];
354
- for (let i = 0; i < paths.length; i++) {
355
- const name = paths[i];
356
- if (existsSync(nodepath.join(outDir, name))) await rm(nodepath.join(outDir, name), { recursive: true });
357
- }
358
- });
359
- },
360
- plugins: env$1 === "development" && process.env.CLI_BUILD !== "true" ? [run({
361
- env: Object.assign({}, process.env, {
362
- NODE_ENV: env$1,
363
- DIST_DIR: outDir
364
- }),
365
- execArgv: ["-r", "source-map-support/register"],
366
- allowRestarts: false,
367
- input: process.cwd() + "/src/server.ts"
368
- })] : []
369
- };
370
- var TsdownConfig_default = TsDownConfig;
371
-
372
- //#endregion
373
- //#region src/Providers/ConsoleServiceProvider.ts
374
- /**
375
- * Handles CLI commands and tooling.
376
- *
377
- * Auto-Registered when in CLI mode
378
- */
379
- var ConsoleServiceProvider = class extends ServiceProvider {
380
- static priority = 992;
381
- /**
382
- * Indicate that this service provider only runs in console
383
- */
384
- static runsInConsole = true;
385
- runsInConsole = true;
386
- register() {}
387
- boot() {
388
- const DIST_DIR = `/${env("DIST_DIR", ".h3ravel/serve")}/`.replaceAll("//", "");
389
- Kernel.init(this.app, {
390
- logo: altLogo,
391
- resolver: new ContainerResolver(this.app).resolveMethodParams,
392
- tsDownConfig: TsdownConfig_default,
393
- packages: [{
394
- name: "@h3ravel/core",
395
- alias: "H3ravel Framework"
396
- }, {
397
- name: "@h3ravel/musket",
398
- alias: "Musket CLI"
399
- }],
400
- cliName: "musket",
401
- hideMusketInfo: true,
402
- discoveryPaths: [app_path("Console/Commands/*.js").replace("/src/", DIST_DIR)]
403
- });
404
- process.on("SIGINT", () => {
405
- process.exit(0);
406
- });
407
- process.on("SIGTERM", () => {
408
- process.exit(0);
409
- });
410
- }
411
- };
412
-
413
- //#endregion
414
- export { BuildCommand, ConsoleServiceProvider, MakeCommand, PostinstallCommand, TsDownConfig };
415
- //# sourceMappingURL=index.js.map