Fractal: Introduce version numbers

Created on 15 Jun 2017  Â·  20Comments  Â·  Source: frctl/fractal

In a workflow where backend developers are integrating frontend components from fractal, it's obligate to have version numbers at the top of the already existing "status". They can then document the used version in their templates to compare them at a later point.

@allmarkedup What do you think about that?

All 20 comments

This has come up before a few times, and whilst version numbers for individual components would be great, there is a lot of hidden complexity here, especially when it comes to components that have subcomponents (which themselves might have subcomponents...). It brings up a lot of questions like whether you have to manually change the version of all parent components when a subcomponent changes, etc.

Because of dependencies between components (and shared assets etc) in my opinion it is much safer to use a single version number for the entire component library and not rely on versioning individual components. The library can be published via NPM and then the versioning is handled via the NPM package version.

Obviously you could also publish individual packages for each component, but there is also a lot of additional workflow complexity in that approach too.

Either way I'm not sure that this is something that Fractal is best placed to assist in without potentially causing more problems than it solves!

I might need to elaborate the use case behind it. We're working with complex backend environments (e.g. CMS, CRM, etc.) and fractal seems to be quite cool because we can implement our frontend components without the backend, which makes it more efficient due to the fact that we don't need to wait multiple seconds after each change for the backend process. But, this also means that we have two redundant code places. One as a backend theme and one using fractal. To make sure that these two are always snychronously, we need to know if there are changes in the corresponding components within the fractal repository. This is were version numbers come into play. We wouldn't need to have them on sub-components, just on root-components due to the fact that in our case, they always include all sub-components. We're just using sub-components to avoid redundant code when having multiple root-components that are using the same sub-components. But I'd recommend to let users choose on their personal needs.

So, to make fractal almost perfect it would be great to introduce version numbers that make components really independently.

// EDIT

Btw.: "status" is also available for each component

For everyone interested in this issue. I'm currently creating a changelog in a README.md file as a workaround.

@julmot I think I understand your issue, but I am not sure if the version number is the correct solution. I think you should find the way to avoid redundant code bases - so you should have separate code base for backend and one for frontend. In our drupal implementation for fractal we have helper and than we are using templates direct from fractal.

Second idea is, that you can still introduce different set of statuses or you can also achieve this with git workflow. ;)

@samuells I'm very interested in this workflow. Do you have e.g. Gitter to chat about that? If so, you can ping me with my username julmot.

@julmot We don't have a gitter, but we are on fractal slack channel - you can ping me there - samuell

@samuells Can you please invite me or send a link? After googling I only found a 502 page: http://slack.fractal.build/

this is the link : http://fractalize.slack.com

@samuells Well, since it's private, you need to invite myself. See my GitHub profile for email address.

Heh, probably I don't have the rights for that. I asked @allmarkedup, how it's possible, because I think it was public slack before.

@julmot page is back online - http://slack.fractal.build/

A simpler approach instead of version numbers could be a hash of a component. The hash would automatically change whenever the HTML of the component changes.

Well, this is the same as auto-incremented version numbers. But, they won't indicate a real HTML change, due to the fact that it would also increment if you'd add a handlebar comment – which is irrelevant for any HTML endpoint.

Except that you don't need any business logic for the auto-increment. When you use version numbers you have to store them somewhere and read them back, while a hash is stateless.

You can strip out any comments and whitespace before calculating the hash.

You can strip out any comments and whitespace before calculating the hash.

That would be acceptable, like comparing the HTML from the HTML panel.

@julmot In cases similar to yours where I've worked with a pattern library and a complex back-end, hashing is the approach we took and it worked well. I'd agree with Mark that this isn't really something Fractal should handle itself.

In this case at least don't repel users that are requesting this feature by saying we won't cover it. As you've confirmed with your personal need for this, it's something common. It would be good if you'd share your experience and knowledge about how to make Fractal to generate hashes automatically.

@julmot I looked into the source code and the easiest approach would be to start off with the render filter and add the hash function. The filter is located here:
https://github.com/frctl/fractal/blob/master/src/web/engine/filters/render.js

The hasha library is already a dependency. It is a wrapper library for the crypto API. That one provides the required md5 or sha1 hashes. You could then add the truncation length as an argument to the filter.

I think adding the functionality to core would be a bit trickier. As far as I can see the rendering happens at the very end of the build pipeline and already includes the layout template.
https://github.com/frctl/fractal/blob/master/src/web/builder.js#L165

Sorry if has nothing to do with this topic, but I only found a reference of it here... @samuells I can't access slack yet.

@mascardoso I can't do anything about it, probably only @allmarkedup can

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sturobson picture sturobson  Â·  6Comments

allmarkedup picture allmarkedup  Â·  7Comments

gui-gui picture gui-gui  Â·  6Comments

coreybruyere picture coreybruyere  Â·  5Comments

eknowles picture eknowles  Â·  6Comments