Skip to content

feat(cli): repeatable --plugin <module[@prefix]> flag (#594)#595

Merged
melvincarvalho merged 3 commits into
gh-pagesfrom
feat/594-plugin-cli-flag
Jul 11, 2026
Merged

feat(cli): repeatable --plugin <module[@prefix]> flag (#594)#595
melvincarvalho merged 3 commits into
gh-pagesfrom
feat/594-plugin-cli-flag

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

Closes #594. Builds on #593.

What

jss start --root ./data --public \
  --plugin ./chat/plugin.js@/chat \
  --plugin @scope/pkg/plugin.js@/app
  • Parsing (parsePluginFlag in src/config.js): split on the last @ followed by / — scoped packages parse unambiguously; a value with no separator is all module, so a malformed prefix (./p.js@chat) becomes a loud import failure rather than a surprise mount.
  • Append, not replace: CLI entries append to the config file's plugins array. The usual CLI-replaces-file rule would make -c + one --plugin silently drop the file's declared apps — the exact silent-missing-app mode the loader refuses.
  • Scope: module + prefix only; per-plugin config/id stay config-file territory. Entries reach loadPlugins untouched, so prefix validation, duplicate-id rejection, and fail-loud imports apply unchanged.
  • Docs: CLI example added to the App Plugins section of docs/configuration.md.

Tests

  • 6 new unit tests for parsePluginFlag (plain, scoped, multiple @, missing-slash prefix); config + plugins suites: 32/32 pass.
  • End-to-end: flag-only server mounts and serves the plugin; -c config.json + --plugin mounts both apps side by side (append verified).

Sets up the servejss side of #592's plan: jsserve can now forward --plugin verbatim and stay a pure flag translator.

Mounts app plugins straight from the CLI, no config file needed:

  jss start --root ./data --public --plugin ./chat/plugin.js@/chat

parsePluginFlag splits on the last '@' followed by '/', so scoped
package specifiers parse unambiguously ('@scope/pkg/plugin.js@/app').
A value with no such separator is all module — a malformed prefix
becomes a loud import failure, never a surprise mount.

CLI entries APPEND to the config file's plugins array instead of
following the CLI-replaces-file rule: replacing would make -c plus one
--plugin silently drop the file's declared apps. Per-plugin config
objects and explicit ids stay config-file territory; entries reach the
loader untouched, so its validation (prefix, duplicate ids,
fail-loudly) applies as-is.

Unit tests for the parser; verified end-to-end: flag-only mounts and
serves, and config-file + flag mount both apps side by side.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repeatable --plugin <module[@prefix]> CLI flag to mount app plugins without requiring a config file, while preserving existing plugin-loader validation semantics by parsing only { module, prefix } and appending CLI entries to any plugins defined in a config file.

Changes:

  • Add parsePluginFlag() to parse module[@prefix] by splitting on the last @/.
  • Add repeatable --plugin support in bin/jss.js, appending parsed entries to config.plugins.
  • Document the new flag in docs/configuration.md and add unit tests for the parsing behavior.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/config.js Adds parsePluginFlag() helper for parsing --plugin flag values.
bin/jss.js Introduces repeatable --plugin option and appends parsed plugin entries to config plugins.
test/config.test.js Adds unit tests covering parsePluginFlag() parsing edge cases (scoped packages, multiple @, etc.).
docs/configuration.md Documents CLI usage of repeatable --plugin flag with examples and merging behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/configuration.md Outdated
Unquoted leading @ is PowerShell splatting syntax (Copilot review).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/config.js
Comment on lines +325 to +332
export function parsePluginFlag(value) {
const str = String(value);
const at = str.lastIndexOf('@/');
if (at > 0) {
return { module: str.slice(0, at), prefix: str.slice(at + 1) };
}
return { module: str };
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — changed to >= 0 in 665e2ac; '@/app' now raises the loader's "each entry needs a module" error (verified via CLI), with a unit test for the case.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.

@melvincarvalho
melvincarvalho merged commit 3db7130 into gh-pages Jul 11, 2026
2 checks passed
@melvincarvalho
melvincarvalho deleted the feat/594-plugin-cli-flag branch July 11, 2026 07:37
melvincarvalho added a commit that referenced this pull request Jul 11, 2026
The --plugin CLI flag (#594, #595): jss start --plugin 'module[@Prefix]'
mounts app plugins with no config file — repeatable, split on the last
'@' followed by '/' so scoped package specifiers parse unambiguously,
and a malformed or missing module fails the boot through the loader's
own validation. CLI entries append to the config file's plugins array
rather than replacing it, so -c plus --plugin composes. With 0.0.216's
config-file forwarding this completes the CLI half of #206: plugins
now load from config.json, from flags, or both. Documented in
docs/configuration.md App Plugins. Remaining: pluginDataDir override
so served trees don't collect .plugins/ (#592), #583 raw-body mode,
#564 feature migration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: repeatable --plugin <module[@prefix]> flag for config-file-free app mounting

2 participants