-
Notifications
You must be signed in to change notification settings - Fork 62
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
Installable Components #28
Comments
I am incredibly excited and supportive on this!! On my phone right now, so I'll just reply with one thing: let's do a folder per pattern/component with all assets inside. We've separated assets in a folder per type for so long, but it's no longer necessary as we have the file extension to tell the difference and we often treat these as source files that are globbed by things like Gulp and compiled to another location. I could see this working great:
|
This is a "just in case" note re:Node. Regular, normal use of Pattern Lab PHP that is shipped out of the Pattern Lab org should in no way rely on Node. I feel really strongly about that. If a feature is officially supported it should work via PHP. Examples include browser reload and source watch in PL1. Both could have used Node but I spent the time to get those working natively in PHP. This limits the language dependencies someone needs to install to get up and running with this. Of course, Editions or StarterKits put out outside the org can support Node, Gulp, Grunt, Sass or whatever. Just for this org the PHP projects should be vanilla PHP on the build side. I want to provide an easy-to-use base that people can build whatever on top of. That's been the ethos from the beginning. Also see the work done to make this project work sans Apache even. I really tried hard to limit dependencies. That said, maybe this issue needs to be defined simply around supporting a default path option in a package install. Example below. Any other clean-up/moving of assets can be implemented at a later date. So PL PHP wouldn't support "components" per se but it's obvious it can be bent that way.
The above would move everything in An array of
This reminds me that I need to add an out for |
@dmolsen You beat me to opening this issue! :) So glad to learn that you are interested in this topic and have been thinking about it already. I just published a blog post containing a lot of my thoughts on how this could be done.
|
@aleksip Take a look at how The Financial Times does their system, Origami: http://origami.ft.com They have each component in its registry in its own repo with its own issue key and the ability to release multiple versions of that component! Some examples:
They each have their own |
@EvanLovely Origami looks very impressive, even a bit overwhelming at first. But yes, a component project manifest file would be something neutral. A The way I'm thinking file/folder mapping could work is that PL would use component project repos 'as is', whether they are inside or outside of the PL project. So there would not be any copying of files. The mapping to |
I definitely think Origami is the most thorough and extreme approach that we could take and is probably overkill for what we're trying to do. It's great inspiration though! I think that keeping this info in a composer.json would be off putting to Node devs as well, just as keeping it in package.json would be off putting to PHP devs. Additionally I am very against any copying of files as I learned that's very confusing for others on the project as they could easily be editing a file that will get overwritten later. I think a components.json would work well and would work if all components were in one repo or there was a single component per repo or any combination of the two. |
From reading @aleksip's post "components" are definitely something that is outside the scope of Pattern Lab. At least in the sense that core PL needs to explicitly support something called components. I can see a few changes that should happen with core:
If a schema like Origami is developed then a plug-in could be created with a rule to read in the data and with custom templates to display that data. The KSS plugin sort of works this way. I would expect that one would end up leaning on NPM/Composer for dependency management. To be clear, |
@dmolsen Thanks for all the work in thinking about this and opening those related issues! My blog post probably made component projects seem more complex than what I'm currently thinking they could be. My current definition of a 'component project' is:
And the definition of 'component folder':
Both definitions are intentionally very loose, as this allows for flexibility. The component(s) themselves can be defined in the manifest file. From PL's point of view 'component folders' just mean 'folders below However, Composer is not the recommended way to install StarterKits, and Ok, now getting to the actual issue(s)... :) The big question still remaining: would it be possible, instead of copying files, to use files directly from StarterKit/pattern project folders containing repository metadata? Will #32 be implemented by copying files or by using a merged in-memory directory, linking to the contents of different real directories? I think #30, #31 and #34 could all be solved by a single JSON schema, as a PL |
@aleksip -
I'm not sure I've explained why this is the case. It touches on your interest in retaining VCS data. Based on what I've experienced here with our CMS, theme developers want a starting point from a moment in time. They're not terribly interested in having "components" under version control or tracked with dependencies. I would say that's a mistake but that's why StarterKits are able to be pulled via ZIP without any of that overhead. They're meant as literally a starting point and then never worrying about conflicts or whatever. That may or may not work for "components." It also avoids a simple mistake like "composer update" and boom you're getting prompted " You can still use Composer to install StarterKits (releases or branches) but definitely trying to help people avoid a few gotchas.
I was thinking it would be a
I agree. |
Didn't know the story behind the non-recommendation. Would be interesting to learn more about the Pattern Lab + CMS setup and development workflow in that type of use case. Even without components and many of the changes discussed in this issue, there is a use case in which a StarterKit is used more like an independent project, with changes committed to its own repo. Composer's
That seems like a great solution! Maybe add a |
PRs welcome ;) I could see a Git wrapper plugin that adds that If one were to go with Composer managing it then I think that a
I think we may be talking past one another a little bit. Can you describe the process by which you expect people to add something that needs to be tracked as an additional |
Good to know! Wouldn't want to do a PR for something like this without your pre-approval of the idea. Also good to learn about the possibility of a plugin approach.
Totally possible! :) So the way I see how mappings could work is that there would not be any restrictions on how a downloaded/configured 'StarterKit' is organized. The mapping file would be a list of source to target mappings, with the targets being specific PL directories. So if I have a Drupal theme organized like this:
The theme could contain a mapping file with something like this (just a very quick sketch): {
"extra": {
"patternlab": {
"starterKitMappings": [
{
"type": "patternDir",
"from": "components/atomic-component-set"
},
{
"type": "pattern",
"from": "components/single-component-1",
"to": "[patternDir]/atoms/forms/textarea"
},
{
"type": "pattern",
"from": "components/single-component-2",
"patternType": "molecules",
"patternSubType": "forms",
"patternName": "comment-form"
},
{
"type": "assets",
"from": "css",
"to": "[sourceDir]/css"
},
{
"type": "sourceDir",
"from": "pattern-lab"
}
]
}
}
} This would make it possible for basically anything with a mapping file to be a Pattern Lab StarterKit. There could be changes made to the Drupal theme which affect the mappings. And when such changes are made, I could just run A stand-alone {
"extra": {
"patternlab": {
"starterKitMappings": [
{
"type": "pattern",
"from": ".",
"patternType": "molecules",
"patternSubType": "forms",
"patternName": "comment-form"
}
]
}
}
} It would be a StarterKit containing just one pattern. I'm voting for changing #32 back to 'Support array for |
I'm going to stay with the mechanics of install, placement and where things live. Sorry. I see where you're going with the schema and have comments but I'd like to nail down these issues first. So we have a Drupal theme with the above layout. Could I run So the question becomes, do you need these files to be in Alternatively, if they're outside PL root there could be a I'm assuming Or we allow supported PL types to be added via a config override/addition in an edition's |
Perfectly fine! First things first. :)
I can't think of any reason why I'd want to dictate the location inside PL. As a general rule I think it would ideal for it to be possible to 1) use StarterKits from (almost) anywhere, 2) use them 'as is' (no copying) and 3) have the possibility to install inside PL with or without VCS metadata. (Is is possible to install dependencies with VCS metadata with Composer?)
So the 'mappings' you refer to is basically just a list of StarterKit directories? If so, couldn't it just be a list in I originally understood that the
If |
👍 We're in agreement then. Though the caveat would be that I don't see PL itself handling VCS on install. That's a serious rabbit hole.
Yes! 😄 This is exactly how I work on Pattern Lab. See the composer.json for the development edition to see how I include the
I might have been overthinking this a little bit with
I phrased that awkwardly. Currently PL checks for a PL-compatible There is value in being able to declare these sort of options once in a way that could be used by PL/PHP or PL/Node. I'm warming to the extra schema. |
True...
I really have to start using Composer this way too.
What do you think of the idea of just using StarterKits for this? That is, with
:) |
Created issue #75 which I see as related to this overall conversation. |
@dmolsen I'd like to have a go, but not sure how to do this. |
@EvanLovely @aleksip @dmolsen I don't want to jump the gun too prematurely but I think I might be on to something here... I managed to get a little POC semi-working today with PL working with a couple Patterns getting managed in a separate directory by Lerna. Gonna try to iron out a couple kinks tomorrow but if this holds up I'll have a bunch more to share / ideas to bounce around. |
@sghoweri Sounds interesting! Looking forward to learning more about your experiments. |
…exist when scanning the pattern source directory for patterns; adds the RecursiveIteratorIterator flag to follow symbolic links while still continuing to skip dots (. and ..). This opens the door for some creative workarounds to the rigid way Pattern Lab expects pattern templates to be organized at the file system level + how the physical path to a pattern determines how it's organized in Pattern Lab... pattern-lab#28
@EvanLovely Any updates here? I got similar needs, also currently working on a proof of concept with lernajs. Might be able to contribute. |
@EvanLovely aren't we essentially doing this with the Bolt v1 Epic setup using the Lerna, Yarn workspaces and the new recursive Twig namespaces config? The fully customizable directory paths work isn't technically required for this, right? Cc @remydenton |
I've been interested in the idea of installable patterns for PL2 for a while now. Once
InstallerUtil
was done I saw that it was more flexible than just installing PatternEngines and StarterKits. Now that there is interest in components and they appear to generally work "installable patterns" can be expanded to "installable components." This would allow the use of something likecomposer require phase2/tabbed-panel
in a project which would install Phase 2's version of a tabbed panel. Alternatively, a StarterKit could consist entirely of component dependencies. Or we allow a "fetch component" feature to keep components out of a dependency tree. All of this is almost doable today. The biggest issues are...I'd like to make the following proposal about Packagist-based components:
composer.json
. e.g.atoms/general
../config
. if that didn't work...Now this works really well for PL2 things like patterns, data, info files. Where it breaks for me are assets like images, javascript, css and sass/less. How magical do we think this needs to be? Plugin assets that are meant to modify the the PL viewer are installed in a way that's pretty damn magical but no one really cares about the final, standardized location for those plugins.
Is this something worth worrying about? Ideas for how to address non-PL2 assets?
The text was updated successfully, but these errors were encountered: