Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract plugins for yarn and ruby to separate responsibilities #87

Merged
merged 51 commits into from
Nov 15, 2022

Conversation

xjunior
Copy link
Contributor

@xjunior xjunior commented Oct 29, 2022

This PR splits CobraCommander into three packages:

  • cobra_commander: the core models of a cobra app (components and umbrella), the CLI, and tools such as graph, tree, and the executor
  • cobra_commander-ruby: the source for ruby packages within a cobra app
  • cobra_commander-yarn: the source for JS/yarn workspaces packages within a cobra app

With this change, a cobra app should now include the core library and the necessary plugins within the cobra bundle group.

The plugins should gain extra responsibility in the near future, like the introduction of Cobra Generators and dependency management (add/remove)

Todo

  • Split cobra into multiple plugins
  • Write proper API documentation for core classes
  • Update README documentation

@xjunior xjunior force-pushed the hfh/plugin-system branch 7 times, most recently from 058a4bd to 5ecaa00 Compare November 4, 2022 02:05
@xjunior xjunior force-pushed the hfh/plugin-system branch 4 times, most recently from d214742 to 68e670a Compare November 9, 2022 15:03
@xjunior xjunior force-pushed the hfh/plugin-system branch 2 times, most recently from c53155a to c4b8c4f Compare November 10, 2022 18:55
@xjunior xjunior changed the title hfh/plugin system Extract plugins for yarn and ruby to separate responsibilities Nov 15, 2022
@xjunior xjunior marked this pull request as ready for review November 15, 2022 02:14
@xjunior xjunior requested a review from a team November 15, 2022 02:14
@@ -0,0 +1,6 @@
module CobraCommander
module Ruby
VERSION: String
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plan on setting types for other files?

Comment on lines +5 to +15
def [](key)
Class.new(self) do
define_singleton_method(:key) { key }
define_method(:key) { key }

def self.inherited(base)
super
superclass.all[key] = base
end
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to have to open a console in here to unpack what this accomplishes. I wasn't familiar with Forwardable.

What is key? Is it a name or a path, or what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not a big fan of how this is right now, but what it achieves is:

I want a class extending the registry to be registered in the registry and have a key attribute used to identify the registered class uniquely within the registry. This key is used to toggle the plugin on/off in the, for instance.

The key is a required class attribute of the source, so I didn't want to just have them define a key, I wanted to initialize it with the inheritance. This is the best I could do.

This defines a class with a key, and once inherited it will register the new class with the given key. The resulting syntax is similar to what AR does with migrations. I wish the code was simpler, but I like the overall solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a category then perhaps? Or possibly a klass? --- Maybe even just a registration_key?

Copy link
Member

@garettarrowood garettarrowood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@xjunior xjunior merged commit 5605a39 into main Nov 15, 2022
@xjunior xjunior deleted the hfh/plugin-system branch November 15, 2022 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants