@arkstack/console 0.9.1 → 0.10.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { config } from "@arkstack/common";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { Arkstack } from "@arkstack/contract";
|
|
3
4
|
import { writeFileSync } from "node:fs";
|
|
4
5
|
|
|
5
6
|
//#region src/prepare/TSConfig.ts
|
|
@@ -50,14 +51,14 @@ var BuildInterfaces = class {
|
|
|
50
51
|
this.buildInterface("ConfigRegistry", items),
|
|
51
52
|
"}"
|
|
52
53
|
].join("\n");
|
|
53
|
-
writeFileSync(path.join(
|
|
54
|
+
writeFileSync(path.join(Arkstack.rootDir(), ".arkstack/ark.d.ts"), declaration, "utf8");
|
|
54
55
|
}
|
|
55
56
|
static tsconfig() {
|
|
56
57
|
const configs = {
|
|
57
58
|
".arkstack/tsconfig.json": JSON.stringify(TSConfig, void 0, 2),
|
|
58
59
|
"tsconfig.json": JSON.stringify(BaseTCConfig, void 0, 2)
|
|
59
60
|
};
|
|
60
|
-
for (const [file, config] of Object.entries(configs)) writeFileSync(path.join(
|
|
61
|
+
for (const [file, config] of Object.entries(configs)) writeFileSync(path.join(Arkstack.rootDir(), file), config, "utf8");
|
|
61
62
|
}
|
|
62
63
|
static isDynamicMap(obj) {
|
|
63
64
|
const keys = Object.keys(obj);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path, { isAbsolute, join } from "node:path";
|
|
2
|
+
import { Arkstack } from "@arkstack/contract";
|
|
2
3
|
import { CliApp } from "resora";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
|
|
@@ -22,11 +23,11 @@ const defaultConfig = (app) => {
|
|
|
22
23
|
//#region dist/app.js
|
|
23
24
|
const resolveStubsDir = (config, options, core) => {
|
|
24
25
|
const configuredDir = config?.localStubsDir;
|
|
25
|
-
if (configuredDir) return isAbsolute(configuredDir) ? configuredDir : join(
|
|
26
|
+
if (configuredDir) return isAbsolute(configuredDir) ? configuredDir : join(Arkstack.rootDir(), configuredDir);
|
|
26
27
|
if (!options?.stubsDir) {
|
|
27
28
|
const driver = core?.getDriver().name ?? "h3";
|
|
28
|
-
let stubsDir = path.resolve(
|
|
29
|
-
if (!existsSync(stubsDir)) stubsDir = path.resolve(
|
|
29
|
+
let stubsDir = path.resolve(Arkstack.rootDir(), `node_modules/@arkstack/driver-${driver}/stubs`);
|
|
30
|
+
if (!existsSync(stubsDir)) stubsDir = path.resolve(Arkstack.rootDir(), "stubs");
|
|
30
31
|
return stubsDir;
|
|
31
32
|
}
|
|
32
33
|
return options?.stubsDir;
|
|
@@ -44,7 +45,7 @@ var ArkstackConsoleApp = class extends CliApp {
|
|
|
44
45
|
this.mergeConfig();
|
|
45
46
|
const normalized = name.endsWith("Controller") ? name.replace(/controller/i, "") : name;
|
|
46
47
|
let controllerName = normalized.endsWith("Controller") ? normalized : `${normalized}Controller`;
|
|
47
|
-
const outputPath = join(path.resolve(
|
|
48
|
+
const outputPath = join(path.resolve(Arkstack.rootDir(), "src", "app/http/controllers"), `${controllerName}.${opts?.ext ?? "ts"}`);
|
|
48
49
|
const stubsDir = resolveStubsDir(this.config, this.options, this.core);
|
|
49
50
|
if (!stubsDir) {
|
|
50
51
|
console.error("Error: stubsDir is not configured. Set stubsDir in resora.config.js.");
|
|
@@ -72,7 +73,7 @@ var ArkstackConsoleApp = class extends CliApp {
|
|
|
72
73
|
* @returns
|
|
73
74
|
*/
|
|
74
75
|
normalizePath = (p) => {
|
|
75
|
-
return p.replace(
|
|
76
|
+
return p.replace(Arkstack.rootDir(), "");
|
|
76
77
|
};
|
|
77
78
|
/**
|
|
78
79
|
* Recursively merge defaultConfig with config from resora.config.js, giving
|
package/dist/app.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as ArkstackConsoleApp } from "./app-
|
|
3
|
-
import { n as BaseTCConfig, r as TSConfig, t as BuildInterfaces } from "./BuildInterfaces-
|
|
2
|
+
import { t as ArkstackConsoleApp } from "./app-DGy8It6S.js";
|
|
3
|
+
import { n as BaseTCConfig, r as TSConfig, t as BuildInterfaces } from "./BuildInterfaces-DQGcpPu2.js";
|
|
4
4
|
import { config, env, importFile, initializeGlobalContext, loadPrototypes, outputDir } from "@arkstack/common";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
import path, { join } from "node:path";
|
|
7
|
+
import { Arkstack } from "@arkstack/contract";
|
|
7
8
|
import { MakeResource } from "resora";
|
|
8
9
|
import { realpathSync } from "node:fs";
|
|
9
10
|
import { Command, Kernel } from "@h3ravel/musket";
|
|
@@ -21,7 +22,7 @@ var BuildCommand = class extends Command {
|
|
|
21
22
|
async handle() {
|
|
22
23
|
await new Promise((resolve, reject) => {
|
|
23
24
|
const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", ["exec", "tsdown"], {
|
|
24
|
-
cwd:
|
|
25
|
+
cwd: Arkstack.rootDir(),
|
|
25
26
|
stdio: "inherit",
|
|
26
27
|
env: Object.assign(process.env, { NODE_ENV: "production" })
|
|
27
28
|
});
|
|
@@ -52,7 +53,7 @@ var DevCommand = class extends Command {
|
|
|
52
53
|
"--log-level",
|
|
53
54
|
"silent"
|
|
54
55
|
], {
|
|
55
|
-
cwd:
|
|
56
|
+
cwd: Arkstack.rootDir(),
|
|
56
57
|
stdio: "inherit",
|
|
57
58
|
env: Object.assign(process.env, { NODE_ENV: "development" })
|
|
58
59
|
});
|
|
@@ -81,7 +82,7 @@ var MakeCommand = class extends Command {
|
|
|
81
82
|
const name = String(this.argument("name")).replace(/\s+/g, "").replace(/\.js$/, "").trim();
|
|
82
83
|
if (!name) return void this.error("Command name is required");
|
|
83
84
|
const stubContent = this.stub(name);
|
|
84
|
-
const filePath = resolve(
|
|
85
|
+
const filePath = resolve(Arkstack.rootDir(), "src", `app/console/commands/${name}.js`);
|
|
85
86
|
await writeFile(filePath, stubContent, { flag: "wx" });
|
|
86
87
|
this.success(`Command ${name} created successfully at ${filePath}`);
|
|
87
88
|
}
|
|
@@ -260,8 +261,8 @@ var logo_default = String.raw`
|
|
|
260
261
|
* @returns
|
|
261
262
|
*/
|
|
262
263
|
const loadCoreApp = async () => {
|
|
263
|
-
const dist = path.relative(
|
|
264
|
-
return (await importFile(join(
|
|
264
|
+
const dist = path.relative(Arkstack.rootDir(), outputDir());
|
|
265
|
+
return (await importFile(join(Arkstack.rootDir(), `${dist}/core/bootstrap.js`))).app;
|
|
265
266
|
};
|
|
266
267
|
/**
|
|
267
268
|
* Runs the console kernel, initializing the application and registering commands.
|
|
@@ -271,7 +272,7 @@ const loadCoreApp = async () => {
|
|
|
271
272
|
const runConsoleKernel = async (options = {}) => {
|
|
272
273
|
loadPrototypes();
|
|
273
274
|
const app = await loadCoreApp();
|
|
274
|
-
const dist = path.relative(
|
|
275
|
+
const dist = path.relative(Arkstack.rootDir(), outputDir());
|
|
275
276
|
const stubsDir = process.env.ARKSTACK_STUBS_DIR;
|
|
276
277
|
globalThis.app = () => app;
|
|
277
278
|
globalThis.env = env;
|
|
@@ -292,12 +293,12 @@ const runConsoleKernel = async (options = {}) => {
|
|
|
292
293
|
MakeCommand
|
|
293
294
|
],
|
|
294
295
|
discoveryPaths: [
|
|
295
|
-
join(
|
|
296
|
-
join(
|
|
297
|
-
join(
|
|
298
|
-
join(
|
|
299
|
-
join(
|
|
300
|
-
join(
|
|
296
|
+
join(Arkstack.rootDir(), "src", "app", "console", "commands/*.js"),
|
|
297
|
+
join(Arkstack.rootDir(), "src", "app/console/commands/*.js"),
|
|
298
|
+
join(Arkstack.rootDir(), "src", "app/console/commands/*.mjs"),
|
|
299
|
+
join(Arkstack.rootDir(), dist, "app/console/commands/*.js"),
|
|
300
|
+
join(Arkstack.rootDir(), dist, "app/console/commands/*.mjs"),
|
|
301
|
+
join(Arkstack.rootDir(), "node_modules", "@arkstack/*", "dist", "commands", "*.js")
|
|
301
302
|
],
|
|
302
303
|
exceptionHandler(exception) {
|
|
303
304
|
throw exception;
|
package/dist/prepare.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as BuildInterfaces } from "./BuildInterfaces-
|
|
2
|
+
import { t as BuildInterfaces } from "./BuildInterfaces-DQGcpPu2.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { Arkstack } from "@arkstack/contract";
|
|
4
5
|
import { existsSync, mkdirSync } from "node:fs";
|
|
5
6
|
import { spawn } from "node:child_process";
|
|
6
7
|
import chalk from "chalk";
|
|
7
8
|
|
|
8
9
|
//#region dist/prepare.js
|
|
9
|
-
if (!existsSync(path.join(
|
|
10
|
+
if (!existsSync(path.join(Arkstack.rootDir(), ".arkstack/build"))) mkdirSync(path.join(Arkstack.rootDir(), ".arkstack/build"), { recursive: true });
|
|
10
11
|
const NODE_ENV = process.env.NODE_ENV || "development";
|
|
11
12
|
const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
|
|
12
13
|
"exec",
|
|
13
14
|
"tsdown",
|
|
14
15
|
"--log-level=silent"
|
|
15
16
|
], {
|
|
16
|
-
cwd:
|
|
17
|
+
cwd: Arkstack.rootDir(),
|
|
17
18
|
stdio: "inherit",
|
|
18
19
|
env: Object.assign({}, process.env, {
|
|
19
20
|
NODE_ENV,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/console",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Console module for Arkstack, providing the command-line runtime and console integration layer.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net/guide/cli",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@h3ravel/support": "^0.15.11",
|
|
51
51
|
"chalk": "^5.6.2",
|
|
52
52
|
"resora": "^1.3.6",
|
|
53
|
-
"@arkstack/common": "^0.
|
|
54
|
-
"@arkstack/contract": "^0.
|
|
53
|
+
"@arkstack/common": "^0.10.0",
|
|
54
|
+
"@arkstack/contract": "^0.10.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsdown",
|