@axium/server 0.7.1 → 0.7.3
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/config.js +2 -2
- package/dist/plugins.js +7 -7
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
2
|
import { levelText } from 'logzen';
|
|
3
3
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { dirname, join } from 'node:path/posix';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path/posix';
|
|
5
5
|
import { deepAssign } from 'utilium';
|
|
6
6
|
import * as z from 'zod';
|
|
7
7
|
import { findDir, logger, output } from './io.js';
|
|
@@ -102,7 +102,7 @@ export async function loadConfig(path, options = {}) {
|
|
|
102
102
|
for (const include of file.include ?? [])
|
|
103
103
|
await loadConfig(join(dirname(path), include), { optional: true });
|
|
104
104
|
for (const plugin of file.plugins ?? [])
|
|
105
|
-
await loadPlugin(plugin);
|
|
105
|
+
await loadPlugin(plugin.startsWith('.') ? resolve(dirname(path), plugin) : plugin);
|
|
106
106
|
}
|
|
107
107
|
export async function loadDefaultConfigs() {
|
|
108
108
|
await loadConfig(findConfigPath(true), { optional: true });
|
package/dist/plugins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
|
-
import { join } from 'node:path/posix';
|
|
2
|
+
import { join, resolve } from 'node:path/posix';
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
4
|
import * as z from 'zod';
|
|
5
5
|
import { fromZodError } from 'zod-validation-error';
|
|
@@ -40,10 +40,6 @@ export function pluginText(plugin) {
|
|
|
40
40
|
].join('\n');
|
|
41
41
|
}
|
|
42
42
|
export async function loadPlugin(specifier) {
|
|
43
|
-
specifier = fileURLToPath(import.meta.resolve(specifier));
|
|
44
|
-
const stats = fs.statSync(specifier);
|
|
45
|
-
if (stats.isDirectory() || !['.js', '.mjs'].some(ext => specifier.endsWith(ext)))
|
|
46
|
-
return;
|
|
47
43
|
try {
|
|
48
44
|
const plugin = await Plugin.parseAsync(await import(specifier)).catch(e => {
|
|
49
45
|
throw fromZodError(e);
|
|
@@ -52,14 +48,18 @@ export async function loadPlugin(specifier) {
|
|
|
52
48
|
output.debug(`Loaded plugin: "${plugin.name}" (${plugin.id}) ${plugin.version}`);
|
|
53
49
|
}
|
|
54
50
|
catch (e) {
|
|
55
|
-
output.debug(`Failed to load plugin from ${specifier}: ${e}`);
|
|
51
|
+
output.debug(`Failed to load plugin from ${specifier}: ${e.message || e}`);
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
export async function loadPlugins(dir) {
|
|
59
55
|
fs.mkdirSync(dir, { recursive: true });
|
|
60
56
|
const files = fs.readdirSync(dir);
|
|
61
57
|
for (const file of files) {
|
|
62
|
-
|
|
58
|
+
const path = resolve(dir, file);
|
|
59
|
+
const stats = fs.statSync(path);
|
|
60
|
+
if (stats.isDirectory() || !['.js', '.mjs'].some(ext => path.endsWith(ext)))
|
|
61
|
+
return;
|
|
62
|
+
await loadPlugin(path);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
export async function loadDefaultPlugins() {
|