@axium/client 0.32.1 → 0.33.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/cli/config.d.ts +9 -1
- package/dist/cli/config.js +6 -2
- package/dist/cli/index.js +16 -69
- package/package.json +2 -2
package/dist/cli/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PluginLoadOptions } from '@axium/core/node/plugins';
|
|
1
2
|
export declare const configDir: string;
|
|
2
3
|
export declare const axcConfigPath: string;
|
|
3
4
|
export declare function session(): {
|
|
@@ -22,5 +23,12 @@ export declare function session(): {
|
|
|
22
23
|
};
|
|
23
24
|
name?: string | null | undefined;
|
|
24
25
|
};
|
|
25
|
-
export
|
|
26
|
+
export interface LoadConfigOptions {
|
|
27
|
+
plugins?: PluginLoadOptions;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param safe whether to run code from plugins
|
|
32
|
+
*/
|
|
33
|
+
export declare function loadConfig(options?: LoadConfigOptions): Promise<void>;
|
|
26
34
|
export declare function saveConfig(): void;
|
package/dist/cli/config.js
CHANGED
|
@@ -18,7 +18,11 @@ export function session() {
|
|
|
18
18
|
io.exit('No session data available.', 3);
|
|
19
19
|
return cache.meta.data.session;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param safe whether to run code from plugins
|
|
24
|
+
*/
|
|
25
|
+
export async function loadConfig(options = {}) {
|
|
22
26
|
try {
|
|
23
27
|
Object.assign(config, io.readJSON(axcConfigPath, ClientConfig));
|
|
24
28
|
if (config.server)
|
|
@@ -26,7 +30,7 @@ export async function loadConfig(safe) {
|
|
|
26
30
|
if (config.token)
|
|
27
31
|
setToken(config.token);
|
|
28
32
|
for (const plugin of config.plugins ?? [])
|
|
29
|
-
await loadPlugin('client', plugin, axcConfigPath,
|
|
33
|
+
await loadPlugin('client', plugin, axcConfigPath, options.plugins);
|
|
30
34
|
}
|
|
31
35
|
catch (e) {
|
|
32
36
|
io.warn('Failed to load config: ' + io.errorText(e));
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import { formatBytes } from '@axium/core';
|
|
3
|
-
import {
|
|
3
|
+
import { createPluginCommand, outputDaemonStatus } from '@axium/core/node';
|
|
4
4
|
import { _findPlugin, plugins } from '@axium/core/plugins';
|
|
5
5
|
import { CommanderError, program } from 'commander';
|
|
6
6
|
import * as io from 'ioium/node';
|
|
@@ -20,11 +20,11 @@ const debug = z.stringbool().default(false).parse(process.env.DEBUG?.toLowerCase
|
|
|
20
20
|
if (debug)
|
|
21
21
|
io._setDebugOutput(true);
|
|
22
22
|
useUserAgent(clientUA);
|
|
23
|
-
await loadConfig(safe);
|
|
23
|
+
await loadConfig({ plugins: { safe } });
|
|
24
24
|
cache.load();
|
|
25
25
|
process.on('SIGHUP', () => {
|
|
26
26
|
io.info('Reloading configuration due to SIGHUP.');
|
|
27
|
-
void loadConfig(safe);
|
|
27
|
+
void loadConfig({ plugins: { safe } });
|
|
28
28
|
});
|
|
29
29
|
program
|
|
30
30
|
.version($pkg.version)
|
|
@@ -74,7 +74,19 @@ program
|
|
|
74
74
|
if (opt.socket && config.token)
|
|
75
75
|
await connectSocket({ rejectUnauthorized: !opt.insecure });
|
|
76
76
|
});
|
|
77
|
-
const axcPlugin =
|
|
77
|
+
const axcPlugin = createPluginCommand('client', program, {
|
|
78
|
+
safe,
|
|
79
|
+
loadedBy: () => axcConfigPath,
|
|
80
|
+
enabled: config.plugins,
|
|
81
|
+
enable(spec) {
|
|
82
|
+
config.plugins.push(spec);
|
|
83
|
+
saveConfig();
|
|
84
|
+
},
|
|
85
|
+
disable(spec) {
|
|
86
|
+
config.plugins = config.plugins.filter(p => p !== spec);
|
|
87
|
+
saveConfig();
|
|
88
|
+
},
|
|
89
|
+
});
|
|
78
90
|
axcPlugin
|
|
79
91
|
.command('run')
|
|
80
92
|
.description('Run a plugin')
|
|
@@ -83,71 +95,6 @@ axcPlugin
|
|
|
83
95
|
const plugin = _findPlugin(search);
|
|
84
96
|
await plugin._client?.run?.();
|
|
85
97
|
});
|
|
86
|
-
axcPlugin
|
|
87
|
-
.command('list')
|
|
88
|
-
.alias('ls')
|
|
89
|
-
.description('List loaded plugins')
|
|
90
|
-
.option('-l, --long', 'use the long listing format')
|
|
91
|
-
.option('--no-versions', 'do not show plugin versions')
|
|
92
|
-
.action(opt => {
|
|
93
|
-
if (!plugins.size) {
|
|
94
|
-
console.log('No plugins loaded.');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (!opt.long) {
|
|
98
|
-
console.log(plugins.keys().toArray().join(', '));
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
console.log(styleText('whiteBright', plugins.size + ' plugin(s) loaded:'));
|
|
102
|
-
for (const plugin of plugins.values()) {
|
|
103
|
-
console.log(plugin.name, opt.versions ? plugin.version : '');
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
axcPlugin
|
|
107
|
-
.command('info')
|
|
108
|
-
.description('Get information about a plugin')
|
|
109
|
-
.argument('<plugin>', 'the plugin to get information about')
|
|
110
|
-
.action((search) => {
|
|
111
|
-
const plugin = _findPlugin(search);
|
|
112
|
-
for (const line of pluginText(plugin))
|
|
113
|
-
console.log(line);
|
|
114
|
-
});
|
|
115
|
-
axcPlugin
|
|
116
|
-
.command('add')
|
|
117
|
-
.description('Add a plugin')
|
|
118
|
-
.option('-k, --keep-going', 'continue adding plugins even if one fails')
|
|
119
|
-
.argument('<spec...>', 'the plugin specifier (e.g. a package name) to add')
|
|
120
|
-
.action(async (specs, { keepGoing }) => {
|
|
121
|
-
for (const spec of specs) {
|
|
122
|
-
try {
|
|
123
|
-
if (config.plugins.includes(spec))
|
|
124
|
-
throw `Plugin "${spec}" is already added.`;
|
|
125
|
-
const plugin = await loadPlugin('client', spec, axcConfigPath, safe);
|
|
126
|
-
if (!plugin)
|
|
127
|
-
throw `Failed to load a client plugin from "${spec}".`;
|
|
128
|
-
config.plugins.push(spec);
|
|
129
|
-
saveConfig();
|
|
130
|
-
console.log('Added plugin:', plugin.name, styleText('dim', 'v' + plugin.version));
|
|
131
|
-
}
|
|
132
|
-
catch (e) {
|
|
133
|
-
if (keepGoing)
|
|
134
|
-
io.error(e);
|
|
135
|
-
else
|
|
136
|
-
io.exit(e);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
axcPlugin
|
|
141
|
-
.command('remove')
|
|
142
|
-
.alias('rm')
|
|
143
|
-
.description('Remove a plugin')
|
|
144
|
-
.argument('<plugin>', 'the plugin to remove')
|
|
145
|
-
.action((search) => {
|
|
146
|
-
const plugin = _findPlugin(search);
|
|
147
|
-
config.plugins = config.plugins.filter(p => p !== plugin.specifier);
|
|
148
|
-
plugins.delete(plugin.name);
|
|
149
|
-
saveConfig();
|
|
150
|
-
});
|
|
151
98
|
const axcCache = program.command('cache').description('Manage the local cache');
|
|
152
99
|
axcCache
|
|
153
100
|
.command('info')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"author": "James Prevett <jp@jamespre.dev>",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"build": "tsc"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@axium/core": ">=0.
|
|
52
|
+
"@axium/core": ">=0.34.0",
|
|
53
53
|
"ioium": "^1.0.2",
|
|
54
54
|
"semver": "^7.7.4",
|
|
55
55
|
"svelte": "^5.36.0",
|