astrolicious / astro-theme-provider

Author themes for Astro like a normal project and export your work as an integration for others to use
https://astro-theme-provider.netlify.app/
The Unlicense
28 stars 2 forks source link

Reduce the `repository` and `homepage` warnings when not present in `package.json` #75

Open lorenzolewis opened 5 months ago

lorenzolewis commented 5 months ago

There are use cases where a user doesn't want to publish their theme (such as if private or just testing something). The warnings that are emitted I feel are a tiny bit over-kill (especially when first getting started with the example repo):

22:34:40 [WARN] [my-theme] Add a 'homepage' to your theme's 'package.json'!     Astro uses this value to populate the integrations page https://astro.build/integrations/

        "homepage": "https://github.com/UserName/theme-playground",

22:34:40 [WARN] [my-theme] Add a 'repository' to your theme's 'package.json'!   Astro uses this value to populate the integrations page https://astro.build/integrations/

        "repository": {
            "type": "git",
            "url": "https://github.com/UserName/my-theme",
            "directory": "package"
        },

If the intention is to use this package for preparing a user to submit their theme to the Astro integration page then maybe a validate command could be added? This could check if everything is correct and also give a developer any additional context.

BryceRussell commented 5 months ago

Thanks for opening an issue on this! I agree, these warnings can feel like overkill, especially for this use case. I haven't documented this yet, but I tried to get around this by adding the ability to silence these warning if the package.json has "private": true or if the log option is set to false. What do you think about this? This does not solve the issue with the template warnings being scary, but the template is meant for packages. Maybe we could fill these properties with default values in the template, so the warnings don't scare anyone.

Context for these warnings: The main reason I want to support these warning is that the integrations page is populated automatically. This means It is possible for user's to publish their package with undefined fields, which makes it harder for people to discover the theme on the integrations page. The goal of these warnings are to make sure that themes authored with ATP follow best practices and are discoverable by the Astro.

lorenzolewis commented 5 months ago

Ahh, awesome! I just tried the "private": true trick and that's exactly what I expected. Possibly just adding a sentence to the log output telling the developer they can do the same would fix it I think. And those who read are annoyed my console messages are maybe those who actually read the messages there and would notice that hint if so ;)

BryceRussell commented 5 months ago

Good idea! 📋 I also plan on writing some docs to cover these options/use cases

BryceRussell commented 5 months ago

If anyone is interested in contributing, this is a great first issue!

Here is the code for these warnings: https://github.com/astrolicious/astro-theme-provider/blob/main/package/src/utils/package.ts#L38

If any of these warnings are triggered, we should also warn that they can be silenced with "private": true inside the package.json