Skip to content

Commit 313d39f

Browse files
forge: FORGE_CONFIG env fallback for CLI --plugin mounts
jspod / `jss --plugin module@prefix` mount a plugin with no per-plugin config object (that's config-file territory). When the FORGE_CONFIG env var names a JSON file, merge it into api.config as DEFAULTS at activate() — so a CLI-mounted forge can still opt into Nostr announce relays, marks/chain, openEdit, etc. Explicit api.config always wins; unset env or an unreadable file is a silent no-op, so existing config-file deployments and the test suite are unaffected (126 tests unchanged).
1 parent fc6e542 commit 313d39f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

forge/plugin.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,17 @@ async function findBackend(config) {
863863

864864
export async function activate(api) {
865865
const prefix = api.prefix || '/forge';
866+
// CLI --plugin mounts (jspod, `jss --plugin module@prefix`) pass no per-plugin
867+
// config. When FORGE_CONFIG names a JSON file, merge it in as DEFAULTS so a
868+
// CLI-mounted forge can still opt into Nostr/marks/etc. Explicit api.config
869+
// wins; unset env or unreadable file is a silent no-op (behavior unchanged).
870+
if (process.env.FORGE_CONFIG) {
871+
try {
872+
api.config = api.config || {};
873+
const fc = JSON.parse(fs.readFileSync(process.env.FORGE_CONFIG, 'utf8'));
874+
for (const k of Object.keys(fc)) if (api.config[k] === undefined) api.config[k] = fc[k];
875+
} catch (e) { api.log?.warn?.(`forge: FORGE_CONFIG load failed: ${e.message}`); }
876+
}
866877
const privateRepos = api.config.privateRepos ?? false;
867878
// Web-edit DEMO relaxation (tier 3.7): when true, the single-file edit
868879
// endpoint accepts ANONYMOUS edits (no owner signature). This is never a

0 commit comments

Comments
 (0)