Creating demos for Build Plugins

Hey all :wave:
I’ve been wanting to create a demo for my Ghost Markdown plugin but I don’t want to create another repo to manage. It would also be cool to use it as a method of testing. Is there a decent approach to this? I tried creating a demo site inside the plugin repo but I’m getting a somewhat meta issue, I can’t use a plugin inside a project of the same name :sweat_smile:.

Hey! I’ve just forked and I’m not getting any errors in the deploy log. Can you give me a bit more info as to the issue you’re seeing? Cheers!

Hey! Here’s a copy of my logs on Netlify:

5:02:29 PM: ❯ Installing plugins
5:02:29 PM:    - netlify-plugin-ghost-markdown
5:02:31 PM: ​
5:02:31 PM: ┌─────────────────────────────┐
5:02:31 PM: │     Dependencies error      │
5:02:31 PM: └─────────────────────────────┘
5:02:31 PM: ​
5:02:31 PM:   Error message
5:02:31 PM:   Error while installing dependencies in /opt/build/repo
5:02:31 PM:   npm ERR! code ENOSELF
5:02:31 PM:   npm ERR! Refusing to install package with name "netlify-plugin-ghost-markdown" under a package
5:02:31 PM:   npm ERR! also called "netlify-plugin-ghost-markdown". Did you name your project the same
5:02:31 PM:   npm ERR! as the dependency you're installing?
5:02:31 PM:   npm ERR!
5:02:31 PM:   npm ERR! For more information, see:
5:02:31 PM:   npm ERR!     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>
5:02:31 PM: ​
5:02:31 PM:   npm ERR! A complete log of this run can be found in:
5:02:31 PM:   npm ERR!     /opt/buildhome/.npm/_logs/2020-04-19T16_02_31_366Z-debug.log

I’m guessing it’s down to this line in the logs:

Refusing to install package with name “netlify-plugin-ghost-markdown” under a package also called “netlify-plugin-ghost-markdown”. Did you name your project the same as the dependency you’re installing?

I’m not necessarily looking to fix my logs, but more find a way to demo my plugin without creating another repo. I’d like the repo that contains my plugin to also be the source of the demo :slight_smile:

I followed the URL which the log dumped out (https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm).

This can be overridden with the --force flag

You’ll want to append this using the NPM_FLAGS env variable, perhaps in netlify.toml over the UI :smile:

1 Like

Surely it can’t be that simple! Haha thank you @Pieparker, I’ll give this a go

1 Like

I tried this @Pieparker with no luck. I did it very briefly though. I think this is more an issue with the Build Plugins and effectively creating demos for those plugins. I want it to be contained within the repo without creating a whole other project just to demonstrate it. It would be nice to know how to approach this sensibly without creating really unique configurations

Hey David :wave:

If you setup your repo like this: https://github.com/DavidWells/netlify-sentry-plugin/ you can have a demo site in the same repo.

The https://github.com/DavidWells/netlify-sentry-plugin/tree/master/test-site folder deploys & the plugin itself is just referenced locally https://github.com/DavidWells/netlify-sentry-plugin/blob/master/netlify.toml#L12-L13

So create a new site with your plugin repo using this pattern and you should be good to go.

Ah great thanks David, this is a good reference point. I think I’m closer, here’s the latest errors I’m getting:

10:48:51 AM:   Error while installing dependencies in /opt/build/repo
10:48:51 AM:   npm ERR! code ENOLOCAL
10:48:51 AM:   npm ERR! Could not install from "../index.js" as it does not contain a package.json file.

So it’s locating the file, but not the package.json? It is there though, so maybe it assumes the demo project should have a package file too? This would be counterintuative though as my demo project is a Jekyll site which may never have a package.json.

I wondered if there was a modules issue, so I copied your .gitignore setup but still no change. Hoping to get this resolved so I can get some debugging done and provide a demo on the plugin :slight_smile:

Edit: Looks like it could be related to this bug :point_down:

Hi @DavidDarnes,

Yes this is the issue you just pointed at. I will update this post as soon as this is fixed.

1 Like

Thanks @ehmicky! As long as we know the issue I’m cool :sweat_smile:

1 Like

Update! I’ve now started cloning the plugin into a folder within the demo. This works with the Netlify CLI locally but not on Netlify itself. Not ideal either but at least allows me to test the plugin in the same project