Coder Social home page Coder Social logo

Comments (5)

nilslice avatar nilslice commented on April 29, 2024

@olliephillips - I like the idea, and agree it would probably be very helpful for quickly getting addons and integrating them into the project.

Hows this for a modified version of your proposal:

# this would run: go get -u github.com/bosssauce/fbscheduler
# and copy that package into ./addons
$ ponzu add github.com/bosssauce/fbscheduler

This way the code completion will work straight away and the addon becomes vendored upon the next build.

I'm concerned that automatically adding _ imports to some file is a fix for behavior that I'm not sure we want to encourage.. will have to get more feedback on what the downside of this could be. My worry is that without explicitly importing the addon package somewhere, we open up ourselves to having to somehow determine if the _ import should be made (and is safe to do so), or add more API & documentation so the developer knows how to trigger this auto import..

I guess its a question of how much "magic" is going on which could end up causing more hurt than good. There is already one instance of this in cmd/ponzu here: https://github.com/ponzu-cms/ponzu/blob/master/cmd/ponzu/main.go#L19 but it's truly necessary so that the whole system knows about content types - which are fundamental. Addons could have unexpected side-effects, like you mention.

What if we added a package to the top-level of Ponzu, similar to the following, and move the content package import there replacing the _ "content" import in cmd/ponzu with _ "startup" import:

startup/run.go

// Package startup is meant to serve as a place to import packages to trigger 
// their initialization, start delayed workers, etc. `startup` is imported by the
// `cmd/ponzu` main package, and is run when the server starts up
package startup 

import (
    _ "github.com/ponzu-cms/ponzu/content"
    _ "github.com/bosssauce/fbscheduler"
)

This offers a place to put addon initialization in the event that an addon isn't tied directly to any one content type, but keeps the auto-initialization explicit (and optional), which I have a feeling will avoid potential issues in the future. Upon building, this startup package would be copied into the vendor directory just like content...

from ponzu.

olliephillips avatar olliephillips commented on April 29, 2024

Yes, add is better than get. Much better. I'll have a stab at that feature if you can use - and not time critical?

Re auto-magically importing addons. Some of what you suggest I will have to digest in the morning - but generally, I think the Addon UX feels a bit odd having to trigger the import in code first, just to see the Addon admin suite in the dashboard.

from ponzu.

nilslice avatar nilslice commented on April 29, 2024

If you'd like to work on the feature, please go for it! And feel free to loop me in whenever needed. I'm typically in the #ponzu channel on this Slack if you'd like to join and discuss:
https://invite.slack.golangbridge.org

Take note that the CLI code changes should be made to the ponzu-cms/ponzu package itself, not a project that you create with ponzu new - and there are some contribution docs in the README. You'll need to run $ go install ./... from the ponzu-cms/ponzu package or if you fork it, from your own fork (then using the -fork flag as shown in the README) - sorry if this is all obvious, just trying to leave notes wherever possible so others might find them if they are having trouble contributing.

I would also suggest familiarizing yourself with the copyAll func here: https://github.com/ponzu-cms/ponzu/blob/master/cmd/ponzu/options.go#L334, as well as the various places it is called.. I think you'll probably want to use that when copying a go get package into ./addons - the build process should already account for anything added into ./addons, but it will be something you'll want to verify manually.

re: addon auto _ imports.. I agree that it feels odd, and maybe we simply document the Addon API in such a way that strongly suggests addon developers only run the addon.Register func in the addon package's init func - and nothing else (unless they know exactly how it will impact the system). I do plan on creating a generator for addons, much like content, so $ ponzu gen addon .... is a way to standardize this a bit.

If we can do that elegantly and practically, then I would feel much better about doing the auto _ import. Also, we will need to clearly document that the auto _ import only happens when using $ ponzu add ... so there is no expectation of it happening when someone simply copy/pastes a package into ./addons

from ponzu.

olliephillips avatar olliephillips commented on April 29, 2024

Thanks, yes I'll look at this. My pleasure.

from ponzu.

nilslice avatar nilslice commented on April 29, 2024

Merged #87. Thank you!

from ponzu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.