Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordFlow (WordPress WorkFlow)

WordFlow (WordPress WorkFlow)

WordCamp Bologna, 19 maggio 2018

Uno sviluppatore attento si è abituato negli anni ad integrare nel proprio flusso di lavoro i propri tool e linguaggi preferiti (webpack, sass, pug, es6, coffeescript, etc.) per il frontend, avere ambienti di lavoro distinti (development, staging, production), usare tutta la potenza della command line.

In questo talk parleremo di come in weLaika abbiamo messo tutto assieme grazie a Wordless, Wordmove e, ovviamente, WP-CLI per unire tutti gli elementi necessari ad un completo (e comodo) workflow dallo sviluppo al deploy.

Usare l’ecosistema di Webpack integrandovi dialetti di programmazione/markup potenti e developer-friendly può essere facile e noi vorremmo condividere il nostro approccio, che usa il nostro plugin Wordless per facilitare il tutto.

Wordmove è un tool molto affermato che ultimamente ha ricevuto nuove feature, importanti bugfix e miglioramenti. Un’introduzione per tutti ed uno sguardo alle novità più interessanti pensiamo possano essere interessanti sia per chi già usa lo strumento, sia per chi ancora non l’ha mai provato.

Entrambi gli strumenti che vorremmo condividere hanno subito modifiche per interagire con wp-cli, strumento che riteniamo fondamentale e che pensiamo sia importante divulgare il più possibile nella community degli sviluppatori come strumento universale.

Filippo Gangi Dino

May 19, 2018
Tweet

More Decks by Filippo Gangi Dino

Other Decks in Technology

Transcript

  1. Install core* ↳ $ wp core download
 ↳ $ wp

    core install *with wp-cli @mukkoo
  2. Install wordless* ↳ $ wp plugin install wordless ↳ $

    wp plugin activate wordless ↳ $ wp wordless theme create new_theme *with wp-cli @mukkoo
  3. ├── assets │ ├── fonts │ ├── images │ ├──

    javascripts │ └── stylesheets ├── config │ ├── initializers │ └── locales ├── node_modules ├── theme │ ├── assets │ ├── helpers │ └── views ├── tmp │ └── README.mdown ├── Procfile ├── index.php ├── package.json ├── screenshot.png ├── style.css ├── webpack.config.js └── yarn.lock theme structure initializers views index.php assets JS stack
  4. Why wordless is good? built-in initialisers webpack: images optimization sass

    transpiling webpack: assets digest (cache) coffeescript transpiling pug interpreter livereload with browsersync @mukkoo
  5. Easy to handle 50+ helpers - link_to(), image_tag() - placeholder_text(),

    placeholder_image() - latest_posts_of_type() - render_view(), render_partial() - and more… @mukkoo
  6. HTML <!DOCTYPE html> <html lang="en"> <head> <title>Pug </title> <script type="text/

    javascript"> if (foo) bar(1 + 5) </script> </head> <body> <h1>Hello Wordcamp! </h1> <div id="container" class=“col"> <h2><%php echo(get_the_title()) %> <p>You are amazing </p> </div> </body> </html> PUG doctype html html(lang="en") head title Pug script(type='text/javascript') if (foo) bar(1 + 5) body h1 Hello Wordcamp! #container.col h2= get_the_title() p You are amazing @mukkoo
  7. css body { font-size: 14px; margin-top: 20px; margin-bottom: 20px; }

    .table { padding: 20px; background-color: #ff0000; } .table __cell { padding: 10px; background-color: #ff0000; } .table __cell—inverse { background-color: #0000ff; } sass $base-font-size: 14px $gutter: 20px $base-color: #ff0000 
 body font-size: $base-font-size margin: top: $gutter bottom: $gutter .table padding: $gutter background-color: $base-color & __cell padding: $gutter / 2 background-color: $base-color &—inverse background-color: #0000ff
  8. javascript (es6) var fill; fill = function(container = “cup”, liquid

    = “coffee”) { return `Filling the ${container} with ${liquid} ...`; }; var result = []; var ingredients = [“coffee”, “milk”, “syrup”, “ice”]; for (i = 0; i < ingredients.length; i ++) { result.push(fill(ingredients(i))); } coffeescript fill = (container = “cup”, liquid = “coffee”) -> `Filling the ${container} with ${liquid} ...` var ingredients = [“coffee”, “milk”, “syrup”, “ice”] result = (fill(elem) for elem in ingredients)
  9. movefile @mukkoo global: sql_adapter: wpcli local: vhost: http: //vhost.local wordpress_path:

    /home/john/sites/your_site database: name: database_name user: user password: password host: localhost production: vhost: http: //example.com wordpress_path: /var/ www/your_site database: name: database_name user: user password: password host: host exclude: - '.git/' ssh: host: host user: user
  10. movefile @mukkoo global: sql_adapter: wpcli local: vhost: http: //vhost.local wordpress_path:

    /home/john/sites/your_site database: name: database_name user: user password: password host: localhost production: vhost: http: //example.com wordpress_path: /var/ www/your_site database: name: database_name user: user password: password host: host exclude: - '.git/' ssh: host: host user: user local: vhost: http: //vhost.local wordpress_path: /home/john/sites/your_site database: name: database_name user: user password: password host: localhost development environment
  11. movefile @mukkoo global: sql_adapter: wpcli local: vhost: http: //vhost.local wordpress_path:

    /home/john/sites/your_site database: name: database_name user: user password: password host: localhost production: vhost: http: //example.com wordpress_path: /var/ www/your_site database: name: database_name user: user password: password host: host exclude: - '.git/' ssh: host: host user: user production environment production: vhost: http: //example.com wordpress_path: /var/ www/your_site database: name: database_name user: user password: password host: host exclude: - '.git/' ssh: host: host user: user
  12. @mukkoo Something goes wrong with production database ↳ $ wordmove

    pull -d Local fix and push to staging ↳ $ wordmove push -e staging —t First deploy ↳ $ wordmove push —all Local plugins update and deploy to production ↳ $ wordmove push -e production —p
  13. @mukkoo .------------------------. | PSYCHIATRIC | | HELP 5¢ | |________________________|

    || .-""" --. || || / \ .-. || || | ._, \ || || \_/`-' '-.,_/ || || (_ (' _)') \ || || /| |\ || || | \ __ / | || || \_).,_____,/}/ || __ ||____;_ --'___'/ ( || |\ || ( __,\ \_/------ || ||\ ||______________________ || |||| | |||| THE DOCTOR | \||| IS [IN] _____| \ || (______) `|___________________ // ||\ //= ||=\ ` `` `