V2 issue (kind of) with plugin.json

@Vortico maybe something is changed at the startup of Rack and there is a bidirectional check on plugins ?

check 1)
a declared slugs in plugin.json (also if declared inactive) must exists in the plug

and

check 2)
modules in a plugin LIB must be declared in the plugin.json

in both cases a FALSE refuse the LOAD of the plugin LIB

In my case is very penalising: I have many experimental modules, that I compile with a FLAG when in DEBUG mode, but are excluded during the final compilation for the RELEASE (leaving them inactive in the plugin.json)

the managing of the plugin.json (where is impossibile to comment out parts, is a json) is very difficult

I’d like a that both checks must be silent, creating the correct array of valid modules making the UNION with a valid plugin.json declaration, and not blocking the load of the full plugin

I can’t see any malign use that could be done of module unused in the package, or undeclared

Or maybe we have to invent a plugin.json extension, or the possibility to load it from a different path ?

thanks!

1 Like

Dear Antonio

I feel for you…
I don’t know if I have understood your usecase/needs a 100% but if I have, and this is indeed the new Rack behaviour, I have made something that might be a solution or workaround for you.

The idea is this:

  • You have a full and slightly annotated plugin.json manifest named “plugin.json.FULL” (could be changed). It contains all your modules, both debug-only and those for release.
  • By running a script with a DEBUG or RELEASE parameter (the flag you mentioned) during your make/compile, you can now generate the finished plugin.json out from that, containing the full load of modules for a DEBUG config, or only the released modules for a RELEASE config.
  • In that way you can automatically deliver a plugin.json that contains only the release modules, or you can have a plugin.json that contains ALL your modules, for developing and testing, that you only use locally.

If this makes any sense and suits your purpose well enough, here’s how it works:

  • You start by renaming the existing NYSTHI plugin.json file to plugin.json.FULL.
  • For each module which is DEBUG only, and should not be included in a RELEASE, you add a "release": false key to the module json, like so:
{  
   "release": false,
   "slug":"MVerb",
   "name":"MVerb Reverb",
   "description":"Reverb based on the MVerb code",
   (snip)
},
  • This annotation/key will be stripped out from the finished, generated plugin.json file.
  • In your make file you include a call to the script, controlled by your flag, that calls it with DEBUG or RELEASE as a second parameter. The first parameter to the script is the directory where the plugin.json.FULL file is located, and where the plugin.json will also be written.

In the following example I have first annotated 3 modules to be "release": false and I am using current directory ( . ) as the directory where the manifest is located:

# Show usage:
$ ./nysthi-manifest.sh
Usage: nysthi-manifest.sh MANIFEST_PATH DEBUG|RELEASE

# Write out a DEBUG plugin.json:
$ ./nysthi-manifest.sh . DEBUG
Wrote 143 modules out of 143 to ./plugin.json

# Write out a RELEASE plugin.json:
$ ./nysthi-manifest.sh . RELEASE
Wrote 140 modules out of 143 to ./plugin.json

You will find the script below, it has been pretty well tested. The only pre-requisite is to install the jq utility which should be easy enough to do on both Linux, MacOS and MSYS2 (Windows), instructions at the top of the script. You need to do the usual chmod +x nysthi-manifest.sh to make it executable and remember to save it with Unix line-endings.

If you can basically use this, but would like some tweaks, I’m happy to do that. If I misunderstood your need, well… at least I tried :slight_smile: Good luck!

#!/bin/bash

# Make the NYSTHI manifest, either DEBUG or RELEASE

# Under MacOS install jq with: brew install jq
# Under Linux install jq with: sudo apt-get install jq #(or similar)
# Under MSYS2 install jq with: pacman -S mingw-w64-x86_64-jq

USAGE="nysthi-manifest.sh MANIFEST_PATH DEBUG|RELEASE"

MANIFEST_PATH="$1"
CONFIG="$2"
FULL_MANIFEST="$MANIFEST_PATH/plugin.json.FULL"
OUTPUT_MANIFEST="$MANIFEST_PATH/plugin.json"

die()
{
	echo "$1" >&2
	exit 1
}

show_tally()
{
	ALL_COUNT="$(cat "$FULL_MANIFEST" | jq -r '.modules[].slug' | wc -l | awk '{print $1}')"
	WRITTEN_COUNT="$(cat "$OUTPUT_MANIFEST" | jq -r '.modules[].slug' | wc -l | awk '{print $1}')"
	echo "Wrote $WRITTEN_COUNT modules out of $ALL_COUNT to $OUTPUT_MANIFEST"
}

write_debug_manifest()
{
	cat "$FULL_MANIFEST" | jq --indent 3 '. | del(.modules[].release)' > "$OUTPUT_MANIFEST"
	show_tally
}

write_release_manifest()
{
	cat "$FULL_MANIFEST" | jq --indent 3 '. | del(.modules[] | select(.release == false))' > "$OUTPUT_MANIFEST"
	show_tally
}

test $# -ne 2 && die "Usage: $USAGE"
test -d "$MANIFEST_PATH" || die "Manifest directory \"$MANIFEST_PATH\" does not exist. Usage: $USAGE"

case "$CONFIG" in
	'DEBUG') write_debug_manifest ;;
	'RELEASE') write_release_manifest ;;
	*) die "Usage: $USAGE"
esac
1 Like

Wasn’t it always like this?

No idea

no,

when I do the final compilation, the extra modules are excluded from the binaries, but they remain in the plugin.json as “disabled”:true"

in V2 this is not currently possible

fYI @LarsBjerregaard @Squinky.Labs

thanks, I’ll test ASAP ! :muscle:

Integrated in my build

all ok! I can run debug and release and forget about the plugin.json :smiley:

grazie mille @LarsBjerregaard !

1 Like

You’re most welcome Antonio, glad to help!

1 Like

I have a solution for you Antonio! Just release them all!!! :stuck_out_tongue:

1 Like