@h3ravel/console 11.15.0-alpha.8 → 11.17.0-alpha.16
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.js +1 -1
- package/bin/prepare.js +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +16 -21
- package/package.json +14 -17
- package/dist/index.cjs +0 -340
package/bin/fire.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import{IApplication as e}from"@h3ravel/contracts";import{Application as t}from"@h3ravel/core";import{importFile as n}from"@h3ravel/shared";import r from"node:path";new class{async app(){let i=process.env.NODE_ENV===`production`,a=i?process.env.DIST_DIR??`.h3ravel/serve`:`src`,o=i?`js`:`ts`,s=[],c=new t(process.cwd(),`Console`),l=r.join(process.cwd(),a,`bootstrap/providers.${o}`);try{let e=await n(l);s.push(...e.default??[])}catch{}let{default:u}=await n(r.join(process.cwd(),a,`bootstrap/app.${o}`));new u().configure(c),c.initialize(s,[`CoreServiceProvider`]).logging(!1).singleton(e,()=>c),await c.handleCommand()}}().app();export{};
|
package/bin/prepare.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e,
|
|
2
|
+
import{FileSystem as e,mainTsconfig as t}from"@h3ravel/shared";import n,{join as r}from"node:path";import{mkdir as i,readdir as a,rm as o,writeFile as s}from"node:fs/promises";import{execa as c}from"execa";import l from"preferred-pm";new class{async prepare(u=`.h3ravel/serve`){let d=(await l(process.cwd()))?.name??`npm`,f=r(process.env.DIST_DIR??u);try{await e.fileExists(f)&&(await a(f)).length>0&&await o(f,{recursive:!0,force:!0}),await e.fileExists(n.join(f,`tsconfig.json`))||(await i(n.join(f.replace(`/serve`,``)),{recursive:!0}),await s(n.join(f.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(t,null,2)))}catch(e){console.log(e.message)}let p={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:f,LOG_LEVEL:`silent`};await c(d,[`tsdown`,`--silent`,`--config-loader`,`native`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:r(process.cwd()),env:Object.assign({},process.env,p)})}}().prepare();export{};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import * as execa0 from "execa";
|
|
3
2
|
import { Command } from "@h3ravel/musket";
|
|
4
3
|
|
|
5
4
|
//#region src/Commands/BuildCommand.d.ts
|
|
@@ -33,7 +32,7 @@ declare class BuildCommand extends Command {
|
|
|
33
32
|
minify: boolean;
|
|
34
33
|
verbosity: number;
|
|
35
34
|
outDir: string;
|
|
36
|
-
}): Promise<void |
|
|
35
|
+
}): Promise<void | import("execa").Result<{
|
|
37
36
|
stdout: "inherit";
|
|
38
37
|
stderr: "inherit";
|
|
39
38
|
cwd: string;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import { Str } from "@h3ravel/support";
|
|
|
10
10
|
import nodepath from "node:path";
|
|
11
11
|
import "@h3ravel/contracts";
|
|
12
12
|
import "@h3ravel/core";
|
|
13
|
-
|
|
14
13
|
//#region src/Commands/BuildCommand.ts
|
|
15
14
|
var BuildCommand = class BuildCommand extends Command {
|
|
16
15
|
/**
|
|
@@ -79,7 +78,7 @@ var BuildCommand = class BuildCommand extends Command {
|
|
|
79
78
|
"tsdown",
|
|
80
79
|
silent,
|
|
81
80
|
"--config-loader",
|
|
82
|
-
"
|
|
81
|
+
"native",
|
|
83
82
|
"-c",
|
|
84
83
|
"tsdown.default.config.ts"
|
|
85
84
|
].filter((e) => e !== null), {
|
|
@@ -94,7 +93,7 @@ var BuildCommand = class BuildCommand extends Command {
|
|
|
94
93
|
"tsdown",
|
|
95
94
|
silent,
|
|
96
95
|
"--config-loader",
|
|
97
|
-
"
|
|
96
|
+
"native",
|
|
98
97
|
"-c",
|
|
99
98
|
"tsdown.default.config.ts"
|
|
100
99
|
].filter((e) => e !== null), {
|
|
@@ -106,7 +105,6 @@ var BuildCommand = class BuildCommand extends Command {
|
|
|
106
105
|
});
|
|
107
106
|
}
|
|
108
107
|
};
|
|
109
|
-
|
|
110
108
|
//#endregion
|
|
111
109
|
//#region src/Commands/KeyGenerateCommand.ts
|
|
112
110
|
var KeyGenerateCommand = class extends Command {
|
|
@@ -126,7 +124,7 @@ var KeyGenerateCommand = class extends Command {
|
|
|
126
124
|
*/
|
|
127
125
|
description = "Set the application key";
|
|
128
126
|
async handle() {
|
|
129
|
-
const config
|
|
127
|
+
const config = {
|
|
130
128
|
key: crypto.randomBytes(32).toString("base64"),
|
|
131
129
|
envPath: base_path(".env"),
|
|
132
130
|
egEnvPath: base_path(".env.example"),
|
|
@@ -134,43 +132,42 @@ var KeyGenerateCommand = class extends Command {
|
|
|
134
132
|
show: this.option("show")
|
|
135
133
|
};
|
|
136
134
|
this.newLine();
|
|
137
|
-
if (!await FileSystem.fileExists(config
|
|
135
|
+
if (!await FileSystem.fileExists(config.envPath)) if (await FileSystem.fileExists(config.egEnvPath)) await copyFile(config.egEnvPath, config.envPath);
|
|
138
136
|
else {
|
|
139
137
|
this.error(".env file not found.");
|
|
140
138
|
this.newLine();
|
|
141
139
|
process.exit(0);
|
|
142
140
|
}
|
|
143
|
-
let content = await readFile(config
|
|
141
|
+
let content = await readFile(config.envPath, "utf8");
|
|
144
142
|
const buf = Buffer.from(content);
|
|
145
|
-
const env
|
|
146
|
-
if (config
|
|
147
|
-
if (!env
|
|
143
|
+
const env = dotenv.parse(buf);
|
|
144
|
+
if (config.show) {
|
|
145
|
+
if (!env.APP_KEY || env.APP_KEY === "") {
|
|
148
146
|
this.error("Application key not set.");
|
|
149
147
|
this.newLine();
|
|
150
148
|
process.exit(0);
|
|
151
149
|
}
|
|
152
|
-
const [enc, key] = env
|
|
150
|
+
const [enc, key] = env.APP_KEY.split(":");
|
|
153
151
|
Logger.log([[enc, "yellow"], [key, "white"]], ":");
|
|
154
152
|
this.newLine();
|
|
155
153
|
process.exit(0);
|
|
156
|
-
} else if (env
|
|
154
|
+
} else if (env.APP_ENV === "production" && !this.option("force")) {
|
|
157
155
|
this.error("Application is currently in production, failed to set key.");
|
|
158
156
|
this.newLine();
|
|
159
157
|
process.exit(1);
|
|
160
158
|
}
|
|
161
159
|
if (/^APP_KEY=.*$/m.test(content)) {
|
|
162
|
-
config
|
|
163
|
-
content = content.replace(/^APP_KEY=.*$/m, `APP_KEY=base64:${config
|
|
160
|
+
config.updated = true;
|
|
161
|
+
content = content.replace(/^APP_KEY=.*$/m, `APP_KEY=base64:${config.key}`);
|
|
164
162
|
} else {
|
|
165
|
-
config
|
|
166
|
-
content = `APP_KEY=base64:${config
|
|
163
|
+
config.updated = false;
|
|
164
|
+
content = `APP_KEY=base64:${config.key}\n\n${content}`;
|
|
167
165
|
}
|
|
168
|
-
await writeFile(config
|
|
166
|
+
await writeFile(config.envPath, content, "utf8");
|
|
169
167
|
this.success("Application key set successfully.");
|
|
170
168
|
this.newLine();
|
|
171
169
|
}
|
|
172
170
|
};
|
|
173
|
-
|
|
174
171
|
//#endregion
|
|
175
172
|
//#region src/Commands/MakeCommand.ts
|
|
176
173
|
var MakeCommand = class extends Command {
|
|
@@ -258,7 +255,6 @@ var MakeCommand = class extends Command {
|
|
|
258
255
|
Logger.split("INFO: View Created", Logger.log(`src/resources/views/${name}.edge`, "gray", false));
|
|
259
256
|
}
|
|
260
257
|
};
|
|
261
|
-
|
|
262
258
|
//#endregion
|
|
263
259
|
//#region src/Commands/PostinstallCommand.ts
|
|
264
260
|
var PostinstallCommand = class extends Command {
|
|
@@ -301,6 +297,5 @@ var PostinstallCommand = class extends Command {
|
|
|
301
297
|
if (!await FileSystem.fileExists(database_path("db.sqlite"))) await writeFile$1(database_path("db.sqlite"), "");
|
|
302
298
|
}
|
|
303
299
|
};
|
|
304
|
-
|
|
305
300
|
//#endregion
|
|
306
|
-
export { BuildCommand, KeyGenerateCommand, MakeCommand, PostinstallCommand };
|
|
301
|
+
export { BuildCommand, KeyGenerateCommand, MakeCommand, PostinstallCommand };
|
package/package.json
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/console",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.17.0-alpha.16",
|
|
4
4
|
"description": "CLI utilities for scaffolding, running migrations, tasks and for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
6
|
"types": "./dist/index.d.ts",
|
|
9
7
|
"exports": {
|
|
10
8
|
".": {
|
|
@@ -48,35 +46,34 @@
|
|
|
48
46
|
"laravel"
|
|
49
47
|
],
|
|
50
48
|
"peerDependencies": {
|
|
51
|
-
"@h3ravel/core": "^
|
|
52
|
-
"@h3ravel/support": "^0.
|
|
49
|
+
"@h3ravel/core": "^2.0.0-alpha.16",
|
|
50
|
+
"@h3ravel/support": "^2.0.0-alpha.16"
|
|
53
51
|
},
|
|
54
52
|
"devDependencies": {
|
|
55
|
-
"@h3ravel/contracts": "^0.
|
|
56
|
-
"typescript": "^
|
|
53
|
+
"@h3ravel/contracts": "^2.0.0-alpha.16",
|
|
54
|
+
"typescript": "^6.0.0"
|
|
57
55
|
},
|
|
58
56
|
"dependencies": {
|
|
59
|
-
"@h3ravel/musket": "^
|
|
60
|
-
"@h3ravel/shared": "^0.
|
|
61
|
-
"@h3ravel/foundation": "^0.
|
|
57
|
+
"@h3ravel/musket": "^1.29.0-alpha.15",
|
|
58
|
+
"@h3ravel/shared": "^2.0.0-alpha.16",
|
|
59
|
+
"@h3ravel/foundation": "^2.0.0-alpha.16",
|
|
62
60
|
"chalk": "^5.6.2",
|
|
63
61
|
"commander": "^14.0.1",
|
|
64
62
|
"dayjs": "^1.11.18",
|
|
65
63
|
"dotenv": "^17.2.3",
|
|
66
|
-
"execa": "^9.6.
|
|
64
|
+
"execa": "^9.6.1",
|
|
67
65
|
"preferred-pm": "^4.1.1",
|
|
68
66
|
"radashi": "^12.6.2",
|
|
69
|
-
"resolve-from": "^5.0.0"
|
|
70
|
-
"tsx": "^4.20.6"
|
|
67
|
+
"resolve-from": "^5.0.0"
|
|
71
68
|
},
|
|
72
69
|
"scripts": {
|
|
73
|
-
"build": "tsdown --config-loader
|
|
74
|
-
"dev": "
|
|
70
|
+
"build": "tsdown --config-loader unrun",
|
|
71
|
+
"dev": "tsdown --watch --config-loader unrun",
|
|
75
72
|
"start": "node dist/index.js",
|
|
76
73
|
"lint": "eslint . --ext .ts",
|
|
77
74
|
"test": "jest --passWithNoTests",
|
|
78
|
-
"musket": "
|
|
79
|
-
"musket:watch": "
|
|
75
|
+
"musket": "pnpm build && node bin/fire.js",
|
|
76
|
+
"musket:watch": "tsdown --watch --config-loader unrun --on-success \"node bin/fire.js\"",
|
|
80
77
|
"release:patch": "pnpm build && pnpm version patch && git add . && git commit -m \"version: bump console package version\" && pnpm publish --tag latest",
|
|
81
78
|
"version-patch": "pnpm version patch"
|
|
82
79
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
let __h3ravel_shared = require("@h3ravel/shared");
|
|
29
|
-
let __h3ravel_musket = require("@h3ravel/musket");
|
|
30
|
-
let execa = require("execa");
|
|
31
|
-
let preferred_pm = require("preferred-pm");
|
|
32
|
-
preferred_pm = __toESM(preferred_pm);
|
|
33
|
-
let fs_promises = require("fs/promises");
|
|
34
|
-
let crypto = require("crypto");
|
|
35
|
-
crypto = __toESM(crypto);
|
|
36
|
-
let dotenv = require("dotenv");
|
|
37
|
-
dotenv = __toESM(dotenv);
|
|
38
|
-
let node_fs_promises = require("node:fs/promises");
|
|
39
|
-
let __h3ravel_support = require("@h3ravel/support");
|
|
40
|
-
let node_path = require("node:path");
|
|
41
|
-
node_path = __toESM(node_path);
|
|
42
|
-
require("@h3ravel/contracts");
|
|
43
|
-
require("@h3ravel/core");
|
|
44
|
-
|
|
45
|
-
//#region src/Commands/BuildCommand.ts
|
|
46
|
-
var BuildCommand = class BuildCommand extends __h3ravel_musket.Command {
|
|
47
|
-
/**
|
|
48
|
-
* The name and signature of the console command.
|
|
49
|
-
*
|
|
50
|
-
* @var string
|
|
51
|
-
*/
|
|
52
|
-
signature = `build
|
|
53
|
-
{--m|minify : Minify your bundle output}
|
|
54
|
-
{--d|dev : Build for dev but don't watch for changes}
|
|
55
|
-
`;
|
|
56
|
-
/**
|
|
57
|
-
* The console command description.
|
|
58
|
-
*
|
|
59
|
-
* @var string
|
|
60
|
-
*/
|
|
61
|
-
description = "Build the app for production";
|
|
62
|
-
async handle() {
|
|
63
|
-
try {
|
|
64
|
-
await this.fire();
|
|
65
|
-
} catch (e) {
|
|
66
|
-
__h3ravel_shared.Logger.error(e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async fire() {
|
|
70
|
-
const outDir = this.option("dev") ? ".h3ravel/serve" : env("DIST_DIR", "dist");
|
|
71
|
-
const minify = this.option("minify");
|
|
72
|
-
const verbosity = this.getVerbosity();
|
|
73
|
-
const debug = verbosity > 0;
|
|
74
|
-
this.newLine();
|
|
75
|
-
await BuildCommand.build({
|
|
76
|
-
outDir,
|
|
77
|
-
minify,
|
|
78
|
-
verbosity,
|
|
79
|
-
debug,
|
|
80
|
-
mute: false
|
|
81
|
-
});
|
|
82
|
-
this.newLine();
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* build
|
|
86
|
-
*/
|
|
87
|
-
static async build({ debug, minify, mute, verbosity, outDir } = {
|
|
88
|
-
mute: false,
|
|
89
|
-
debug: false,
|
|
90
|
-
minify: false,
|
|
91
|
-
verbosity: 0,
|
|
92
|
-
outDir: "dist"
|
|
93
|
-
}) {
|
|
94
|
-
const pm = (await (0, preferred_pm.default)(base_path()))?.name ?? "pnpm";
|
|
95
|
-
const ENV_VARS = {
|
|
96
|
-
EXTENDED_DEBUG: debug ? "true" : "false",
|
|
97
|
-
CLI_BUILD: "true",
|
|
98
|
-
NODE_ENV: "production",
|
|
99
|
-
DIST_DIR: outDir,
|
|
100
|
-
DIST_MINIFY: minify,
|
|
101
|
-
LOG_LEVEL: [
|
|
102
|
-
"silent",
|
|
103
|
-
"info",
|
|
104
|
-
"warn",
|
|
105
|
-
"error"
|
|
106
|
-
][verbosity]
|
|
107
|
-
};
|
|
108
|
-
const silent = ENV_VARS.LOG_LEVEL === "silent" ? "--silent" : null;
|
|
109
|
-
if (mute) return await (0, execa.execa)(pm, [
|
|
110
|
-
"tsdown",
|
|
111
|
-
silent,
|
|
112
|
-
"--config-loader",
|
|
113
|
-
"unconfig",
|
|
114
|
-
"-c",
|
|
115
|
-
"tsdown.default.config.ts"
|
|
116
|
-
].filter((e) => e !== null), {
|
|
117
|
-
stdout: "inherit",
|
|
118
|
-
stderr: "inherit",
|
|
119
|
-
cwd: base_path(),
|
|
120
|
-
env: Object.assign({}, process.env, ENV_VARS)
|
|
121
|
-
});
|
|
122
|
-
const type = outDir === "dist" ? "Production" : "Development";
|
|
123
|
-
return await __h3ravel_shared.TaskManager.advancedTaskRunner([[`Creating ${type} Bundle`, "STARTED"], [`${type} Bundle Created`, "COMPLETED"]], async () => {
|
|
124
|
-
await (0, execa.execa)(pm, [
|
|
125
|
-
"tsdown",
|
|
126
|
-
silent,
|
|
127
|
-
"--config-loader",
|
|
128
|
-
"unconfig",
|
|
129
|
-
"-c",
|
|
130
|
-
"tsdown.default.config.ts"
|
|
131
|
-
].filter((e) => e !== null), {
|
|
132
|
-
stdout: "inherit",
|
|
133
|
-
stderr: "inherit",
|
|
134
|
-
cwd: base_path(),
|
|
135
|
-
env: Object.assign({}, process.env, ENV_VARS)
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/Commands/KeyGenerateCommand.ts
|
|
143
|
-
var KeyGenerateCommand = class extends __h3ravel_musket.Command {
|
|
144
|
-
/**
|
|
145
|
-
* The name and signature of the console command.
|
|
146
|
-
*
|
|
147
|
-
* @var string
|
|
148
|
-
*/
|
|
149
|
-
signature = `key:generate
|
|
150
|
-
{--force: Force the operation to run when in production}
|
|
151
|
-
{--show: Display the key instead of modifying files}
|
|
152
|
-
`;
|
|
153
|
-
/**
|
|
154
|
-
* The console command description.
|
|
155
|
-
*
|
|
156
|
-
* @var string
|
|
157
|
-
*/
|
|
158
|
-
description = "Set the application key";
|
|
159
|
-
async handle() {
|
|
160
|
-
const config$1 = {
|
|
161
|
-
key: crypto.default.randomBytes(32).toString("base64"),
|
|
162
|
-
envPath: base_path(".env"),
|
|
163
|
-
egEnvPath: base_path(".env.example"),
|
|
164
|
-
updated: false,
|
|
165
|
-
show: this.option("show")
|
|
166
|
-
};
|
|
167
|
-
this.newLine();
|
|
168
|
-
if (!await __h3ravel_shared.FileSystem.fileExists(config$1.envPath)) if (await __h3ravel_shared.FileSystem.fileExists(config$1.egEnvPath)) await (0, fs_promises.copyFile)(config$1.egEnvPath, config$1.envPath);
|
|
169
|
-
else {
|
|
170
|
-
this.error(".env file not found.");
|
|
171
|
-
this.newLine();
|
|
172
|
-
process.exit(0);
|
|
173
|
-
}
|
|
174
|
-
let content = await (0, fs_promises.readFile)(config$1.envPath, "utf8");
|
|
175
|
-
const buf = Buffer.from(content);
|
|
176
|
-
const env$1 = dotenv.default.parse(buf);
|
|
177
|
-
if (config$1.show) {
|
|
178
|
-
if (!env$1.APP_KEY || env$1.APP_KEY === "") {
|
|
179
|
-
this.error("Application key not set.");
|
|
180
|
-
this.newLine();
|
|
181
|
-
process.exit(0);
|
|
182
|
-
}
|
|
183
|
-
const [enc, key] = env$1.APP_KEY.split(":");
|
|
184
|
-
__h3ravel_shared.Logger.log([[enc, "yellow"], [key, "white"]], ":");
|
|
185
|
-
this.newLine();
|
|
186
|
-
process.exit(0);
|
|
187
|
-
} else if (env$1.APP_ENV === "production" && !this.option("force")) {
|
|
188
|
-
this.error("Application is currently in production, failed to set key.");
|
|
189
|
-
this.newLine();
|
|
190
|
-
process.exit(1);
|
|
191
|
-
}
|
|
192
|
-
if (/^APP_KEY=.*$/m.test(content)) {
|
|
193
|
-
config$1.updated = true;
|
|
194
|
-
content = content.replace(/^APP_KEY=.*$/m, `APP_KEY=base64:${config$1.key}`);
|
|
195
|
-
} else {
|
|
196
|
-
config$1.updated = false;
|
|
197
|
-
content = `APP_KEY=base64:${config$1.key}\n\n${content}`;
|
|
198
|
-
}
|
|
199
|
-
await (0, fs_promises.writeFile)(config$1.envPath, content, "utf8");
|
|
200
|
-
this.success("Application key set successfully.");
|
|
201
|
-
this.newLine();
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/Commands/MakeCommand.ts
|
|
207
|
-
var MakeCommand = class extends __h3ravel_musket.Command {
|
|
208
|
-
/**
|
|
209
|
-
* The name and signature of the console command.
|
|
210
|
-
*
|
|
211
|
-
* @var string
|
|
212
|
-
*/
|
|
213
|
-
signature = `#make:
|
|
214
|
-
{controller : Create a new controller class.
|
|
215
|
-
| {--a|api : Exclude the create and edit methods from the controller}
|
|
216
|
-
| {--m|model= : Generate a resource controller for the given model}
|
|
217
|
-
| {--r|resource : Generate a resource controller class}
|
|
218
|
-
| {--force : Create the controller even if it already exists}
|
|
219
|
-
}
|
|
220
|
-
{resource : Create a new resource.
|
|
221
|
-
| {--c|collection : Create a resource collection}
|
|
222
|
-
| {--force : Create the resource even if it already exists}
|
|
223
|
-
}
|
|
224
|
-
{command : Create a new Musket command.
|
|
225
|
-
| {--command : The terminal command that will be used to invoke the class}
|
|
226
|
-
| {--force : Create the class even if the console command already exists}
|
|
227
|
-
}
|
|
228
|
-
{view : Create a new view.
|
|
229
|
-
| {--force : Create the view even if it already exists}
|
|
230
|
-
}
|
|
231
|
-
{^name : The name of the [name] to generate}
|
|
232
|
-
`;
|
|
233
|
-
/**
|
|
234
|
-
* The console command description.
|
|
235
|
-
*
|
|
236
|
-
* @var string
|
|
237
|
-
*/
|
|
238
|
-
description = "Generate component classes";
|
|
239
|
-
async handle() {
|
|
240
|
-
const command = this.dictionary.baseCommand ?? this.dictionary.name;
|
|
241
|
-
if (!this.argument("name")) this.program.error("Please provide a valid name for the " + command);
|
|
242
|
-
await this[{
|
|
243
|
-
controller: "makeController",
|
|
244
|
-
resource: "makeResource",
|
|
245
|
-
view: "makeView",
|
|
246
|
-
command: "makeCommand"
|
|
247
|
-
}[command]]();
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Create a new controller class.
|
|
251
|
-
*/
|
|
252
|
-
async makeController() {
|
|
253
|
-
const type = this.option("api") ? "-resource" : "";
|
|
254
|
-
const name = this.argument("name");
|
|
255
|
-
const force = this.option("force");
|
|
256
|
-
const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
|
|
257
|
-
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
|
|
258
|
-
const path$2 = app_path(`Http/Controllers/${name}.ts`);
|
|
259
|
-
/** The Controller is scoped to a path make sure to create the associated directories */
|
|
260
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$2, "/"), { recursive: true });
|
|
261
|
-
/** Check if the controller already exists */
|
|
262
|
-
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$2)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
|
|
263
|
-
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
264
|
-
stub = stub.replace(/{{ name }}/g, name);
|
|
265
|
-
await (0, node_fs_promises.writeFile)(path$2, stub);
|
|
266
|
-
__h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$2), "gray", false));
|
|
267
|
-
}
|
|
268
|
-
makeResource() {
|
|
269
|
-
__h3ravel_shared.Logger.success("Resource support is not yet available");
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Create a new Musket command
|
|
273
|
-
*/
|
|
274
|
-
makeCommand() {
|
|
275
|
-
__h3ravel_shared.Logger.success("Musket command creation is not yet available");
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Create a new view.
|
|
279
|
-
*/
|
|
280
|
-
async makeView() {
|
|
281
|
-
const name = this.argument("name");
|
|
282
|
-
const force = this.option("force");
|
|
283
|
-
const path$2 = base_path(`src/resources/views/${name}.edge`);
|
|
284
|
-
/** The view is scoped to a path make sure to create the associated directories */
|
|
285
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$2, "/"), { recursive: true });
|
|
286
|
-
/** Check if the view already exists */
|
|
287
|
-
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$2)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
|
|
288
|
-
await (0, node_fs_promises.writeFile)(path$2, `{{-- src/resources/views/${name}.edge --}}`);
|
|
289
|
-
__h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region src/Commands/PostinstallCommand.ts
|
|
295
|
-
var PostinstallCommand = class extends __h3ravel_musket.Command {
|
|
296
|
-
/**
|
|
297
|
-
* The name and signature of the console command.
|
|
298
|
-
*
|
|
299
|
-
* @var string
|
|
300
|
-
*/
|
|
301
|
-
signature = "postinstall";
|
|
302
|
-
/**
|
|
303
|
-
* The console command description.
|
|
304
|
-
*
|
|
305
|
-
* @var string
|
|
306
|
-
*/
|
|
307
|
-
description = "Default post installation command";
|
|
308
|
-
async handle() {
|
|
309
|
-
this.genEncryptionKey();
|
|
310
|
-
this.createSqliteDB();
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Create sqlite database if none exist
|
|
314
|
-
*
|
|
315
|
-
* @returns
|
|
316
|
-
*/
|
|
317
|
-
async genEncryptionKey() {
|
|
318
|
-
new KeyGenerateCommand(this.app, this.kernel).setProgram(this.program).setOption("force", true).setOption("silent", true).setOption("quiet", true).setInput({
|
|
319
|
-
force: true,
|
|
320
|
-
silent: true,
|
|
321
|
-
quiet: true
|
|
322
|
-
}, [], [], {}, this.program).handle();
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Create sqlite database if none exist
|
|
326
|
-
*
|
|
327
|
-
* @returns
|
|
328
|
-
*/
|
|
329
|
-
async createSqliteDB() {
|
|
330
|
-
if (config("database.default") !== "sqlite") return;
|
|
331
|
-
if (!await __h3ravel_shared.FileSystem.fileExists(database_path())) await (0, node_fs_promises.mkdir)(database_path(), { recursive: true });
|
|
332
|
-
if (!await __h3ravel_shared.FileSystem.fileExists(database_path("db.sqlite"))) await (0, node_fs_promises.writeFile)(database_path("db.sqlite"), "");
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
//#endregion
|
|
337
|
-
exports.BuildCommand = BuildCommand;
|
|
338
|
-
exports.KeyGenerateCommand = KeyGenerateCommand;
|
|
339
|
-
exports.MakeCommand = MakeCommand;
|
|
340
|
-
exports.PostinstallCommand = PostinstallCommand;
|