diff --git a/README.md b/README.md index 70cd9be..7da388a 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,9 @@ Or use directly with npx: npx servejss ``` -servejss requires JSS >= 0.0.211, which never writes `index.html` or `.acl` -files into the served directory. If the bundled dependency is missing, +servejss requires JSS >= 0.0.217, which never writes `index.html` or `.acl` +files into the served directory and supports `--plugin` app mounting. +If the bundled dependency is missing, servejss falls back to a globally installed `jss` — if you have an old global install, update it too: @@ -66,7 +67,7 @@ servejss --read-only Local: http://localhost:3000 Network: http://192.168.1.5:3000 - Mode: GET/PUT/DELETE enabled + Mode: GET/PUT/DELETE enabled (public, no auth) Press Ctrl+C to stop ``` @@ -111,6 +112,7 @@ Options: --no-port-switching Do not open a different port if specified one is taken -r, --read-only Disable PUT/DELETE methods (like npx serve) --solid Enable full Solid protocol features + --plugin Mount a JSS app plugin (repeatable) -q, --quiet Suppress all output -h, --help Display help ``` @@ -186,6 +188,16 @@ servejss --read-only ~/shared-files servejss ./mock-data ``` +### Static Site + Live App +```bash +# Serve a directory AND mount a JSS app plugin beside it +servejss --plugin './chat/plugin.js@/chat' ./public +``` + +The plugin value is forwarded verbatim to JSS (`module[@prefix]`, repeatable — +see the [App Plugins docs](https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/blob/gh-pages/docs/configuration.md#app-plugins-plugins)). +Quote it: a leading `@` in scoped packages trips up some shells. + ### WebDAV Alternative ```bash # Lightweight file sync server — no auth, trusted networks only diff --git a/bin/jsserve.js b/bin/jsserve.js index 10e5418..3105d37 100644 --- a/bin/jsserve.js +++ b/bin/jsserve.js @@ -72,7 +72,7 @@ function getNetworkAddress() { * Print the startup banner */ function printBanner(options) { - const { port, host, directory, readOnly, live, solid, networkAddress } = options; + const { port, host, directory, readOnly, live, solid, plugins, networkAddress } = options; const local = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`; const network = networkAddress ? `http://${networkAddress}:${port}` : null; @@ -94,6 +94,9 @@ function printBanner(options) { } console.log(); console.log(` ${chalk.gray('Mode:')} ${chalk.yellow(mode)}`); + if (plugins && plugins.length) { + console.log(` ${chalk.gray('Plugins:')} ${chalk.magenta(plugins.join(', '))}`); + } if (live) { console.log(` ${chalk.gray('Live:')} ${chalk.green('Watching for changes')}`); } @@ -138,6 +141,7 @@ program .option('--no-live', 'Disable live reload') .option('--git', 'Enable git HTTP backend (default: true)') .option('--no-git', 'Disable git HTTP backend') + .option('--plugin ', 'Mount a JSS app plugin (repeatable; requires JSS >= 0.0.217)', (value, previous) => previous.concat([value]), []) .option('-q, --quiet', 'Suppress all output') .addHelpText('after', ` Examples: @@ -267,6 +271,11 @@ async function run(directory, options) { jssArgs.push('--git'); } + // App plugins — forwarded verbatim; JSS owns parsing and loading (#594) + for (const plugin of options.plugin) { + jssArgs.push('--plugin', plugin); + } + // Debug mode if (options.debug) { console.log(chalk.gray(' JSS args:'), jssArgs.join(' ')); @@ -281,6 +290,7 @@ async function run(directory, options) { readOnly: options.readOnly, live: options.live !== false, solid: options.solid, + plugins: options.plugin, networkAddress: getNetworkAddress(), }); } diff --git a/package-lock.json b/package-lock.json index afcae19..15981ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "servejss", - "version": "0.0.8", + "version": "0.0.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "servejss", - "version": "0.0.8", + "version": "0.0.9", "license": "MIT", "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0", - "javascript-solid-server": ">=0.0.211" + "javascript-solid-server": ">=0.0.217" }, "bin": { "servejss": "bin/jsserve.js" @@ -1155,9 +1155,9 @@ } }, "node_modules/javascript-solid-server": { - "version": "0.0.212", - "resolved": "https://registry.npmjs.org/javascript-solid-server/-/javascript-solid-server-0.0.212.tgz", - "integrity": "sha512-ryDWnz/j7wpWJRWT4XSHTtjspTzocVANQzsKKDABClDsULvZ/qb3CcuPMRZKEofsvkOloGHvZ4bFrQd2dK5vbg==", + "version": "0.0.217", + "resolved": "https://registry.npmjs.org/javascript-solid-server/-/javascript-solid-server-0.0.217.tgz", + "integrity": "sha512-oqN+hs9jBDwJVmdRx0BnJX8BP0830GjbI5UincKWCVB4weDeQ4a2bc18sJrtCoK2TJP2s96Ql6e3BY5ql/BBkQ==", "license": "AGPL-3.0-only", "dependencies": { "@fastify/middie": "^8.3.3", diff --git a/package.json b/package.json index 4270aff..3d2ba27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "servejss", - "version": "0.0.8", + "version": "0.0.9", "description": "Static file server with REST write support - npx serve alternative", "keywords": [ "serve", @@ -27,7 +27,7 @@ "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0", - "javascript-solid-server": ">=0.0.211" + "javascript-solid-server": ">=0.0.217" }, "repository": { "type": "git",