Unable to package backend plugin properly

Hello everyone,

I’m very new to grafana plugin development. I’ve managed to create a streaming datasource and i want to publish it on the plugin directory.

Sadly i’m having problems packaging it and i could really use your help.

This is my repo => relay-grafana/arjunpreetham49-relay-datasource at v1.0.0 · Realtime-Relay/relay-grafana · GitHub

In this repo, there is a build.sh file which i run to build the plugin (along with mage for the backend bit)

In the end of it, a zip file of the plugin is created with the binaries and frontend files. I create a release and upload the zip file to it.

To verify the plugin, i run => npx -y @grafana/plugin-validator@latest -sourceCodeUri https://github.com/Realtime-Relay/relay-grafana/tree/v1.0.0 https://github.com/Realtime-Relay/relay-grafana/releases/download/v1.0.0/arjunpreetham49-relay-datasource-1.0.0.zip

But this throws a LOT of errors which i can’t seem to figure out for the life of me. I can understand the README errors (this is lower in priority) but how do i solve the other errors?

error: Could not find or parse package.json from /var/folders/_c/hvrmgqmd1qn5w7dytnh4rqx00000gn/T/validator274574463/
detail: The package.json inside the provided source code can't be parsed or doesn't exist.
warning: unsigned plugin
detail: This is a new (unpublished) plugin. This is expected during the initial review process. Please allow the review to continue, and a member of our team will inform you when your plugin can be signed.
error: go.mod can not be found in your source code
detail: You have indicated your plugin uses a backend (backend=true), but go.mod can not be found in your source code. If your plugin has a backend component you must use go (golang)
error: README.md: convert relative link to absolute: docs/ds_setup.png
detail: README.md contains relative links. These links will not work on the Grafana plugin's catalog. Convert them to absolute links. (starting with https://)
error: README.md: convert relative link to absolute: docs/graph_setup.png
detail: README.md contains relative links. These links will not work on the Grafana plugin's catalog. Convert them to absolute links. (starting with https://)
error: README.md: convert relative link to absolute: docs/demo_gif.gif
detail: README.md contains relative links. These links will not work on the Grafana plugin's catalog. Convert them to absolute links. (starting with https://)
error: Invalid Go manifest file: arjunpreetham49-relay-datasource/Magefile.go
detail: file arjunpreetham49-relay-datasource/Magefile.go is in the source code but not in the manifest
error: Invalid Go manifest file: arjunpreetham49-relay-datasource/pkg/main.go
detail: file arjunpreetham49-relay-datasource/pkg/main.go is in the source code but not in the manifest
error: Invalid Go manifest file: arjunpreetham49-relay-datasource/pkg/models/settings.go
detail: file arjunpreetham49-relay-datasource/pkg/models/settings.go is in the source code but not in the manifest
error: Invalid Go manifest file: arjunpreetham49-relay-datasource/pkg/plugin/datasource.go
detail: file arjunpreetham49-relay-datasource/pkg/plugin/datasource.go is in the source code but not in the manifest
error: Invalid Go manifest file: arjunpreetham49-relay-datasource/pkg/plugin/datasource_test.go
detail: file arjunpreetham49-relay-datasource/pkg/plugin/datasource_test.go is in the source code but not in the manifest
error: Invalid Go manifest file: arjunpreetham49-relay-datasource/pkg/plugin/query.go
detail: file arjunpreetham49-relay-datasource/pkg/plugin/query.go is in the source code but not in the manifest
error: Invalid Go manifest file: arjunpreetham49-relay-datasource/pkg/plugin/relay.go
detail: file arjunpreetham49-relay-datasource/pkg/plugin/relay.go is in the source code but not in the manifest
error: Invalid Go manifest file: pkg/plugin/query.go
detail: pkg/plugin/query.go is in the manifest but not in source code
error: Invalid Go manifest file: pkg/plugin/relay.go
detail: pkg/plugin/relay.go is in the manifest but not in source code
error: Invalid Go manifest file: Magefile.go
detail: Magefile.go is in the manifest but not in source code
error: Invalid Go manifest file: pkg/main.go
detail: pkg/main.go is in the manifest but not in source code
error: Invalid Go manifest file: pkg/models/settings.go
detail: pkg/models/settings.go is in the manifest but not in source code
error: Invalid Go manifest file: pkg/plugin/datasource.go
detail: pkg/plugin/datasource.go is in the manifest but not in source code
error: Invalid Go manifest file: pkg/plugin/datasource_test.go
detail: pkg/plugin/datasource_test.go is in the manifest but not in source code
error: The provided javascript/typescript source code does not match your plugin archive assets.
detail: Verify the provided source code is the same as the one used to generate plugin archive. If you are providing a git repository URL make sure to include the correct ref (branch or tag) in the URL. 
 
The following 5 file(s) differ when comparing source map with source code.
 - ./components/QueryEditor.tsx
 - ./types.ts
 - ./datasource.ts
 - ./module.ts
 - ./components/ConfigEditor.tsx

Any help would be really appreciated! Thank you!

Hi @arjunpreetham49

I advice against custom scripts to package your plugin and since you are using github I it is best you use our github action for building a plugin

I can see you have that already set up in your repository and I can also see a release and the archive files looks fine (though unsigned).

You can use (and I encourage you to use) the zip file from this release for your distribution or submission to review

all you have to do is push a version tag to your repository. I see you are using npm so it should be something like npm version patch (or minor, or major) and then git push origin main --tags

The errors you are seeing with the validator are because you have your plugin inside a subfolder. you should be passing https://github.com/Realtime-Relay/relay-grafana/tree/v1.0.0/arjunpreetham49-relay-datasource instead of only https://github.com/Realtime-Relay/relay-grafana/tree/v1.0.0/ because otherwise the validator is trying to find all the files in the root folder, where they are not.

I noticed there’s nothing else in your root folder besides the grafana plugin. It is best if you simply put the plugin files in the root folder, the subfolder is unnecessary.

Worked like a charm. Thank you so much @academo :smiley: