@arkstack/console 0.1.28 → 0.1.29
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/app-CQsshUJ7.js +77 -0
- package/dist/app.js +1 -52
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import path, { isAbsolute, join } from "node:path";
|
|
2
|
+
import { CliApp } from "resora";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
|
|
5
|
+
//#region dist/config.js
|
|
6
|
+
const defaultConfig = {
|
|
7
|
+
resourcesDir: "dist/app/http/resources",
|
|
8
|
+
localStubsDir: "node_modules/@arkstack/driver-h3/stubs",
|
|
9
|
+
stubs: {
|
|
10
|
+
resource: "resource.stub",
|
|
11
|
+
collection: "resource.collection.stub",
|
|
12
|
+
controller: "controller.stub",
|
|
13
|
+
api: "controller.api.stub",
|
|
14
|
+
model: "controller.model.stub",
|
|
15
|
+
apiResource: "controller.api.resource.stub"
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region dist/app.js
|
|
21
|
+
const resolveStubsDir = (config, options, core) => {
|
|
22
|
+
const configuredDir = config?.localStubsDir;
|
|
23
|
+
if (configuredDir) return isAbsolute(configuredDir) ? configuredDir : join(process.cwd(), configuredDir);
|
|
24
|
+
if (!options?.stubsDir) {
|
|
25
|
+
const driver = core?.getDriver().name ?? "h3";
|
|
26
|
+
let stubsDir = path.resolve(process.cwd(), `node_modules/@arkstack/driver-${driver}/stubs`);
|
|
27
|
+
if (!existsSync(stubsDir)) stubsDir = path.resolve(process.cwd(), "stubs");
|
|
28
|
+
return stubsDir;
|
|
29
|
+
}
|
|
30
|
+
return options?.stubsDir;
|
|
31
|
+
};
|
|
32
|
+
var ArkstackConsoleApp = class extends CliApp {
|
|
33
|
+
core;
|
|
34
|
+
options;
|
|
35
|
+
constructor(core, options) {
|
|
36
|
+
super();
|
|
37
|
+
this.core = core;
|
|
38
|
+
this.options = options;
|
|
39
|
+
this.config = {
|
|
40
|
+
...defaultConfig,
|
|
41
|
+
...this.config,
|
|
42
|
+
stubs: {
|
|
43
|
+
...defaultConfig.stubs,
|
|
44
|
+
...this.config?.stubs
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
makeController = (name, opts) => {
|
|
49
|
+
const normalized = name.endsWith("Controller") ? name.replace(/controller/i, "") : name;
|
|
50
|
+
let controllerName = normalized.endsWith("Controller") ? normalized : `${normalized}Controller`;
|
|
51
|
+
const outputPath = join(path.resolve(process.cwd(), "src", "app/http/controllers"), `${controllerName}.${opts?.ext ?? "ts"}`);
|
|
52
|
+
const stubsDir = resolveStubsDir(this.config, this.options, this.core);
|
|
53
|
+
if (!stubsDir) {
|
|
54
|
+
console.error("Error: stubsDir is not configured. Set stubsDir in resora.config.js.");
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
const stubPath = join(stubsDir, opts.model ? this.config.stubs.model : opts.api ? this.config.stubs.api : this.config.stubs.controller);
|
|
58
|
+
if (!existsSync(stubPath)) {
|
|
59
|
+
console.error(`Error: Stub file ${stubPath} not found.`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
controllerName = controllerName.split("/").pop();
|
|
63
|
+
this.generateFile(stubPath, outputPath, {
|
|
64
|
+
ControllerName: controllerName,
|
|
65
|
+
Model: opts.model?.pascalCase(),
|
|
66
|
+
ModelName: opts.model?.camelCase(),
|
|
67
|
+
Name: controllerName.replace(/controller/i, "")
|
|
68
|
+
}, opts);
|
|
69
|
+
return outputPath;
|
|
70
|
+
};
|
|
71
|
+
normalizePath = (p) => {
|
|
72
|
+
return p.replace(process.cwd(), "");
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
export { resolveStubsDir as n, ArkstackConsoleApp as t };
|
package/dist/app.js
CHANGED
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CliApp } from "resora";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
1
|
+
import { n as resolveStubsDir, t as ArkstackConsoleApp } from "./app-CQsshUJ7.js";
|
|
4
2
|
|
|
5
|
-
//#region dist/app.js
|
|
6
|
-
const resolveStubsDir = (config, options, core) => {
|
|
7
|
-
const configuredDir = config?.localStubsDir;
|
|
8
|
-
if (configuredDir) return isAbsolute(configuredDir) ? configuredDir : join(process.cwd(), configuredDir);
|
|
9
|
-
if (!options?.stubsDir) {
|
|
10
|
-
const driver = core?.getDriver().name ?? "h3";
|
|
11
|
-
let stubsDir = path.resolve(process.cwd(), `node_modules/@arkstack/driver-${driver}/stubs`);
|
|
12
|
-
if (!existsSync(stubsDir)) stubsDir = path.resolve(process.cwd(), "stubs");
|
|
13
|
-
return stubsDir;
|
|
14
|
-
}
|
|
15
|
-
return options?.stubsDir;
|
|
16
|
-
};
|
|
17
|
-
var ArkstackConsoleApp = class extends CliApp {
|
|
18
|
-
core;
|
|
19
|
-
options;
|
|
20
|
-
constructor(core, options) {
|
|
21
|
-
super();
|
|
22
|
-
this.core = core;
|
|
23
|
-
this.options = options;
|
|
24
|
-
}
|
|
25
|
-
makeController = (name, opts) => {
|
|
26
|
-
const normalized = name.endsWith("Controller") ? name.replace(/controller/i, "") : name;
|
|
27
|
-
let controllerName = normalized.endsWith("Controller") ? normalized : `${normalized}Controller`;
|
|
28
|
-
const outputPath = join(path.resolve(process.cwd(), "src", "app/http/controllers"), `${controllerName}.${opts?.ext ?? "ts"}`);
|
|
29
|
-
const stubsDir = resolveStubsDir(this.config, this.options, this.core);
|
|
30
|
-
if (!stubsDir) {
|
|
31
|
-
console.error("Error: stubsDir is not configured. Set stubsDir in resora.config.js.");
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
const stubPath = join(stubsDir, opts.model ? this.config.stubs.model : opts.api ? this.config.stubs.api : this.config.stubs.controller);
|
|
35
|
-
if (!existsSync(stubPath)) {
|
|
36
|
-
console.error(`Error: Stub file ${stubPath} not found.`);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
controllerName = controllerName.split("/").pop();
|
|
40
|
-
this.generateFile(stubPath, outputPath, {
|
|
41
|
-
ControllerName: controllerName,
|
|
42
|
-
Model: opts.model?.pascalCase(),
|
|
43
|
-
ModelName: opts.model?.camelCase(),
|
|
44
|
-
Name: controllerName.replace(/controller/i, "")
|
|
45
|
-
}, opts);
|
|
46
|
-
return outputPath;
|
|
47
|
-
};
|
|
48
|
-
normalizePath = (p) => {
|
|
49
|
-
return p.replace(process.cwd(), "");
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
3
|
export { ArkstackConsoleApp, resolveStubsDir };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/console",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Console package for Arkstack providing console-specific implementations of core Arkstack features such as routing, middleware, and database integration.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@h3ravel/musket": "^0.10.1",
|
|
50
50
|
"chalk": "^5.6.2",
|
|
51
51
|
"resora": "^0.2.14",
|
|
52
|
-
"@arkstack/common": "^0.1.
|
|
53
|
-
"@arkstack/contract": "^0.1.
|
|
52
|
+
"@arkstack/common": "^0.1.29",
|
|
53
|
+
"@arkstack/contract": "^0.1.29"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsdown",
|