javascript-solid-server 0.0.215 → 0.0.217
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/jss.js +17 -1
- package/docs/configuration.md +14 -0
- package/package.json +1 -1
- package/src/config.js +23 -0
- package/test/config.test.js +42 -1
package/bin/jss.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import { Command } from 'commander';
|
|
13
13
|
import { createServer } from '../src/server.js';
|
|
14
|
-
import { loadConfig, saveConfig, printConfig, defaults } from '../src/config.js';
|
|
14
|
+
import { loadConfig, saveConfig, printConfig, defaults, parsePluginFlag } from '../src/config.js';
|
|
15
15
|
import { createInvite, listInvites, revokeInvite } from '../src/idp/invites.js';
|
|
16
16
|
import { findByUsername, updatePassword, deleteAccount } from '../src/idp/accounts.js';
|
|
17
17
|
import { setQuotaLimit, getQuotaInfo, reconcileQuota, formatBytes } from '../src/storage/quota.js';
|
|
@@ -157,6 +157,7 @@ program
|
|
|
157
157
|
.option('--mcp', 'Enable MCP (Model Context Protocol) server at /mcp — pod as a tool surface for agents (#490)')
|
|
158
158
|
.option('--no-mcp', 'Disable MCP server')
|
|
159
159
|
.option('-q, --quiet', 'Suppress log output')
|
|
160
|
+
.option('--plugin <module[@prefix]>', 'Mount an app plugin (repeatable; prefix must start with /). Appends to config-file plugins (#594)', (value, previous) => previous.concat([value]), [])
|
|
160
161
|
.option('--log-level <level>', 'Log level: error, warn, info, debug (default: info)')
|
|
161
162
|
.option('--print-config', 'Print configuration and exit')
|
|
162
163
|
.action(async (options) => {
|
|
@@ -169,6 +170,16 @@ program
|
|
|
169
170
|
|
|
170
171
|
const config = await loadConfig(options, options.config);
|
|
171
172
|
|
|
173
|
+
// --plugin entries APPEND to the config file's plugins rather than
|
|
174
|
+
// following the CLI-replaces-file rule — replacing would make -c plus
|
|
175
|
+
// one --plugin silently drop the file's declared apps (#594).
|
|
176
|
+
if (options.plugin?.length) {
|
|
177
|
+
config.plugins = [
|
|
178
|
+
...(Array.isArray(config.plugins) ? config.plugins : []),
|
|
179
|
+
...options.plugin.map(parsePluginFlag),
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
|
|
172
183
|
// Set DATA_ROOT env var so all modules use the same data directory
|
|
173
184
|
process.env.DATA_ROOT = path.resolve(config.root);
|
|
174
185
|
|
|
@@ -268,6 +279,11 @@ program
|
|
|
268
279
|
mongoUrl: config.mongoUrl,
|
|
269
280
|
mongoDatabase: config.mongoDatabase,
|
|
270
281
|
mcp: config.mcp,
|
|
282
|
+
// Config-file-only keys (no CLI flags yet): omitting them here made
|
|
283
|
+
// the documented `-c config.json` route silently boot without the
|
|
284
|
+
// declared apps (#592).
|
|
285
|
+
appPaths: config.appPaths,
|
|
286
|
+
plugins: config.plugins,
|
|
271
287
|
});
|
|
272
288
|
|
|
273
289
|
await server.listen({ port: config.port, host: config.host });
|
package/docs/configuration.md
CHANGED
|
@@ -433,6 +433,20 @@ plugins never attach their own `'upgrade'` listener. Return
|
|
|
433
433
|
A plugin that fails to import or activate fails `listen()` loudly rather
|
|
434
434
|
than booting a server silently missing an app.
|
|
435
435
|
|
|
436
|
+
The simple module + prefix case also works straight from the CLI, no
|
|
437
|
+
config file needed ([#594](https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/594)):
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
jss start --root ./data --public \
|
|
441
|
+
--plugin './chat/plugin.js@/chat' \
|
|
442
|
+
--plugin '@scope/pkg/plugin.js@/app'
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
`--plugin` is repeatable; the prefix separator is the last `@` followed by
|
|
446
|
+
`/`, so scoped package names parse unambiguously. CLI entries **append** to
|
|
447
|
+
any `plugins` array from the config file (they don't replace it). Per-plugin
|
|
448
|
+
`config` objects and explicit `id`s remain config-file-only.
|
|
449
|
+
|
|
436
450
|
## Storage Quotas
|
|
437
451
|
|
|
438
452
|
Limit storage per pod to prevent abuse and manage resources:
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -310,6 +310,29 @@ function loadEnvConfig() {
|
|
|
310
310
|
return config;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Parse one --plugin flag value: module[@prefix] (#594).
|
|
315
|
+
*
|
|
316
|
+
* The prefix separator is the LAST '@' whose remainder starts with '/',
|
|
317
|
+
* so scoped package specifiers parse unambiguously:
|
|
318
|
+
* '@scope/pkg/plugin.js@/app' -> { module: '@scope/pkg/plugin.js', prefix: '/app' }
|
|
319
|
+
* '@scope/pkg/plugin.js' -> { module: '@scope/pkg/plugin.js' }
|
|
320
|
+
* './chat/plugin.js@/chat' -> { module: './chat/plugin.js', prefix: '/chat' }
|
|
321
|
+
*
|
|
322
|
+
* Per-plugin config objects and explicit ids stay config-file territory;
|
|
323
|
+
* entries here go through the loader's usual validation untouched.
|
|
324
|
+
*/
|
|
325
|
+
export function parsePluginFlag(value) {
|
|
326
|
+
const str = String(value);
|
|
327
|
+
const at = str.lastIndexOf('@/');
|
|
328
|
+
if (at >= 0) {
|
|
329
|
+
// at === 0 yields module: '' ('@/app' has no module) — the loader's
|
|
330
|
+
// "each entry needs a module" beats a confusing import error.
|
|
331
|
+
return { module: str.slice(0, at), prefix: str.slice(at + 1) };
|
|
332
|
+
}
|
|
333
|
+
return { module: str };
|
|
334
|
+
}
|
|
335
|
+
|
|
313
336
|
/**
|
|
314
337
|
* Load configuration from a JSON file
|
|
315
338
|
*/
|
package/test/config.test.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { describe, it, before, after, beforeEach } from 'node:test';
|
|
11
11
|
import assert from 'node:assert';
|
|
12
|
-
import { loadConfig } from '../src/config.js';
|
|
12
|
+
import { loadConfig, parsePluginFlag } from '../src/config.js';
|
|
13
13
|
|
|
14
14
|
describe('config — env var boolean coercion', () => {
|
|
15
15
|
// Save/restore the env vars we touch so this test is hermetic.
|
|
@@ -190,3 +190,44 @@ describe('config — singleUserName default (#348)', () => {
|
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
});
|
|
193
|
+
|
|
194
|
+
describe('config — parsePluginFlag (#594)', () => {
|
|
195
|
+
it('parses module with prefix', () => {
|
|
196
|
+
assert.deepStrictEqual(parsePluginFlag('./chat/plugin.js@/chat'),
|
|
197
|
+
{ module: './chat/plugin.js', prefix: '/chat' });
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('parses bare module (no prefix)', () => {
|
|
201
|
+
assert.deepStrictEqual(parsePluginFlag('./chat/plugin.js'),
|
|
202
|
+
{ module: './chat/plugin.js' });
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('parses scoped package with prefix — scope @ is not the separator', () => {
|
|
206
|
+
assert.deepStrictEqual(parsePluginFlag('@scope/pkg/plugin.js@/app'),
|
|
207
|
+
{ module: '@scope/pkg/plugin.js', prefix: '/app' });
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('parses bare scoped package as module only', () => {
|
|
211
|
+
assert.deepStrictEqual(parsePluginFlag('@scope/pkg/plugin.js'),
|
|
212
|
+
{ module: '@scope/pkg/plugin.js' });
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('splits on the LAST @/ when several occur', () => {
|
|
216
|
+
assert.deepStrictEqual(parsePluginFlag('pkg@/weird/path.js@/mount'),
|
|
217
|
+
{ module: 'pkg@/weird/path.js', prefix: '/mount' });
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('leaves a prefix without leading slash to the loader to reject', () => {
|
|
221
|
+
// '@chat' has no '@/', so the whole value is the module — the import
|
|
222
|
+
// fails loudly rather than mounting somewhere unexpected.
|
|
223
|
+
assert.deepStrictEqual(parsePluginFlag('./p.js@chat'),
|
|
224
|
+
{ module: './p.js@chat' });
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('parses a missing module to module: "" for the loader to reject', () => {
|
|
228
|
+
// '@/app' splits at position 0 so the loader raises its clear
|
|
229
|
+
// "each entry needs a module" error instead of a confusing import failure.
|
|
230
|
+
assert.deepStrictEqual(parsePluginFlag('@/app'),
|
|
231
|
+
{ module: '', prefix: '/app' });
|
|
232
|
+
});
|
|
233
|
+
});
|