plone / bobtemplates.plone

Python Code Templates for Plone Projects with mr.bob
https://pypi.org/project/bobtemplates.plone/
GNU General Public License v2.0
24 stars 31 forks source link

theme_barceloneta: grunt setup broken #374

Open djowett opened 5 years ago

djowett commented 5 years ago

I've encountered issues with using this subtemplate - mainly that CSS is not compiled, therefore there is no theme.

Fixes I've made that seem to be getting me there:

1) upgrade npm - see https://github.com/nodesource/distributions (3.5 in Ubuntu 18.04 is not enough )

2) Move Gruntfile.js and package.json mv ./src/<my>/<theme>/Gruntfile.js . mv ./src/<my>/<theme>/package.json .

3) Fix @barceloneta_path in theme.less - add a "../" (Possibly make the same fix for @bootstrap_path)

@barceloneta_path: "../barceloneta/less";

I'm not sure if this was the original intent, but does this help? @erral @MrTango

djowett commented 5 years ago

Also - should Gruntfile.js (and package.json?) really be in .gitignore?

djowett commented 5 years ago

https://github.com/plone/bobtemplates.plone/blob/master/bobtemplates/plone/theme_barceloneta/DEVELOP_THEME.rst.bob#L38 says: "The grunt setup is outside of the theme folder in the package root. " but that is not the case, which is IIUC what point 2 above is correcting.

erral commented 5 years ago

According to the folder structure, Gruntfile.js should be created on the package level and not in the 'theme' folder:

https://github.com/plone/bobtemplates.plone/tree/master/bobtemplates/plone/theme_barceloneta

I have made a quick test and I see that the generated file structure is like this:

(plonecli) erral@lindari:/tmp$ plonecli create addon erral.test
(plonecli) erral@lindari:/tmp$ cd erral.test/
(plonecli) erral@lindari:/tmp/erral.test(master)$ plonecli add theme_barceloneta
(plonecli) erral@lindari:/tmp/erral.test(master)$ cd src/erral/test
(plonecli) erral@lindari:/tmp/erral.test/src/erral/test(master)$ ls -la
guztira 72
drwxr-xr-x 7 erral erral 4096 mai  2 08:01 .
drwxr-xr-x 3 erral erral 4096 mai  2 08:01 ..
drwxr-xr-x 4 erral erral 4096 mai  2 08:01 browser
-rw-r--r-- 1 erral erral 1446 mai  2 08:01 configure.zcml
-rw-r--r-- 1 erral erral 1633 mai  2 08:01 DEVELOP_THEME.rst
-rw-r--r-- 1 erral erral 3261 mai  2 08:01 Gruntfile.js
-rw-r--r-- 1 erral erral  127 mai  2 08:01 __init__.py
-rw-r--r-- 1 erral erral  259 mai  2 08:01 interfaces.py
drwxr-xr-x 3 erral erral 4096 mai  2 08:01 locales
-rw-r--r-- 1 erral erral  419 mai  2 08:01 package.json
-rw-r--r-- 1 erral erral  260 mai  2 08:01 permissions.zcml
drwxr-xr-x 4 erral erral 4096 mai  2 08:01 profiles
-rw-r--r-- 1 erral erral  611 mai  2 08:01 setuphandlers.py
-rw-r--r-- 1 erral erral 1444 mai  2 08:01 testing.py
drwxr-xr-x 3 erral erral 4096 mai  2 08:01 tests
drwxr-xr-x 7 erral erral 4096 mai  2 08:01 theme
-rw-r--r-- 1 erral erral  202 mai  2 08:01 upgrades.py
-rw-r--r-- 1 erral erral  379 mai  2 08:01 upgrades.zcml

This subtemplate tries to copy the former theme_package (still present at https://github.com/plone/bobtemplates.plone/tree/master/bobtemplates/plone/theme_package but deprecated).

Now that I compare both, I see that the Gruntfile.js was present on the very first level on the old template and is inside the package on the new subtemplate. I don't recall the details, but when I created the subtemplate I may might have had problems to create the topmost Gruntfile.js and that's why I created it in the package folder.

Anyway, if with the 2 changes you say the setup can be fixed, please provide a PR and I will be happy to review and merge it.

agitator commented 5 years ago

fyi i'm working on updating theme_barceloneta in https://github.com/plone/bobtemplates.plone/pull/373 I'm also a bit confused by the current grunt setup and will discuss that with @MrTango

djowett commented 5 years ago

Sorry - I'm a part-time plonista - evenings only, so you won't get a PR too soon! I don't know how to get mr.bob to copy outside of it's cwd. Is that possible?

MrTango commented 5 years ago

We have at least two ways to solve this. We could choose the template to have the root at the package root not just the theme folder. This way we have to put everything relative to the package root in the template folder, but we could deliver files to the root folder this way too.

Another way would be, to copy the stuff we need via the theme_barceloneta.py from the theme folder up to the package folder. We could also inject the needed buildout config file for the buildout commands this way. In the theme_package template, we create a buildout config which has some commands for installing npm packages on package and theme level as well as run the grunt command once after creation. But if we want to have the same in the combination of "addon" template + "theme_barceloneta" template, we need to update the existing buildout.cfg at least with an extend of a theme.cfg which can come with the theme template. This has to be done in theme_barceloneta.py. Parsing buildout files is not really easy, because is not a standard ini-file. But we could have a placeholder marker inside the from the adon template provided buildout.cfg and insert an extend line there.

MrTango commented 5 years ago

@djowett I think putting the Bundler files as Grunt and so on inside the theme folder is not a great idea. I have done that and it results in a very big theme file, when you want to zip the theme folder. Thats why i separated this in the original theme_package template. Inside the theme folder, only requirements of the theme it self are installed.

MrTango commented 5 years ago

If someone wants to work on it, I'll help. But currently I don't see time and motivation on this side for me to do it.