Automating theme initialization (with a Yeoman generator ?)

Hello,

We develop a lot of themes based on Sage, and we would like to provide a way to automate the steps we take every time we start a new project.

Overview

When Sage 8 was released, @ben mentioned the idea of implementing a Yeoman generator for Sage. Sage 9 is now in alpha version on the master branch, but there is no official Yeoman generator yet. We have made a very simple Yeoman generator-sage as a proof of concept (forked from kdo/generator-wp-underscores). It currently works with Sage 8 and it is available at npmjs.com as well as github.com

We would like to have a collaborative talk to check if our approach is right, and find out more precisely what a Sage generator should do.

We have two open issues :

  1. What are the steps that we want to automate ?
  2. What is the best way of doing it ?

Steps

For the steps we should take when starting a Sage based theme, we have thought of the following :

  1. Update the style.css theme headers
  2. Change the theme namespace
  3. Change the theme text domain
  4. Remove the .github folder
  5. Remove the CHANGELOG.md, but keep LICENSE.md
  6. Replace sage occurrences and urls in bower.json, composer.json and package.json
  7. Update lang/sage.pot
  8. Choose which Soil modules should be active, and ask for modules options when needed
  9. Create an acf-json directory with a .gitkeep file inside (optional)
  10. Choose a frontend framework (bootstrap should not be the only choice) and update the dependencies files (Does this becomes simpler with Sage 9 ?)

Open issues

For now, the Yeoman generator approach seems to be working, but we are not sure if this is the best way. We would like to discuss it with you before further development (specially before we adapt the generator to Sage 9).

Do you agree with the above steps ?

Do you have any other project for automating those steps ?

Do you have any recommendations if we go further with Yeoman ?

The final purpose of an automated Sage starting process would be to provide multiple ways of getting your theme ready :

  • Via the command line with the generator installed on your server
  • With a web interface via a web browser, like the solution provided by http://underscores.me/
  • Using http / curl requests: we should be able to build archives of initialized themes by querying a public endpoint, and allowing shell or wp-cli scripts to construct Sage based themes in a simple way.

Bests regards,

Pierre

1 Like

I just love your generator, very nice work.
I don’t understand the acf-json folder for the plugin ACF, what is that?
How do you use this folder with ACF?
Merci Pierre :slight_smile: I will use your generator.
EDIT:
I got a problem with the namespace after Roots it’s backslash or anti-slash and not a slash:

namespace Roots/Xav\Setup;

use Roots/Xav\Assets;

Take a look here for details on ACF local JSON. It’s cool but I tend to need my fields registered with PHP for easier editing.

1 Like

"caching and both dramatically speeds up ACF and allows for version control over your field settings!"
I think it seems a nice argument, I used ACF and it so slow…

Hello,

Thank you for using the generator,

  1. acf-json : for now, it seems the best way to allow version control on acf fields, without breaking the ability to edit the fields in back-office (thanks to the sync functionnality of acf-pro). But it is more an acf discussion (there is a lot of other threads about this)

  2. namespace : the generator replaces Roots\Sage with the value given in command-line, so I think you just used a wrong value : you should replace Roots\Sage with Organization\Project or something like this, according to http://php.net/manual/en/language.namespaces.nested.php

Bests regards,

Pierre