Download - Sthlm.js 2013: Yeoman workflow

Transcript
Page 1: Sthlm.js 2013: Yeoman workflow

YEOMAN WORKFLOW INTRODUCTION TO

Page 2: Sthlm.js 2013: Yeoman workflow

AGENDA Introduction

Overview Yeoman

•  Yo •  Bower •  Grunt

Demo

Page 3: Sthlm.js 2013: Yeoman workflow

INTRO

WHO AND WHAT

Page 4: Sthlm.js 2013: Yeoman workflow

JOHN-PHILIP “JP” JOHANSSON UX Developer @ Avanade Twitter: @seriemajp GitHub: https://github.com/seriema Grunt crusade:

•  Twitter Bootstrap •  Raphaël •  Holder.js •  FooTable

Upcoming: http://npmalerts.com

Page 5: Sthlm.js 2013: Yeoman workflow

WHAT JavaScript projects are getting bigger

Better tools are needed Tools enable workflows

Yeoman is a workflow

Page 6: Sthlm.js 2013: Yeoman workflow

OVERVIEW

WHAT IS YEOMAN

Page 7: Sthlm.js 2013: Yeoman workflow

YEOMAN WORKFLOW

Create a new webapp Handle dependencies Preview, test, build

$ yo webapp $ bower search jquery $ bower install jquery

$ grunt server $ grunt test $ grunt

Page 8: Sthlm.js 2013: Yeoman workflow

STRUCTURE

OS

Env

App

Page 9: Sthlm.js 2013: Yeoman workflow

STRUCTURE

OS

Env

App

package.json

Page 10: Sthlm.js 2013: Yeoman workflow

PACKAGE.JSON

Page 11: Sthlm.js 2013: Yeoman workflow

PROJECT STRUCTURE bower_components/

node_modules/ bower.json

Gruntfile.js

package.json

Page 12: Sthlm.js 2013: Yeoman workflow

PROJECT STRUCTURE bower_components/ Don’t commit these folders

node_modules/ bower.json

Gruntfile.js

package.json

Page 13: Sthlm.js 2013: Yeoman workflow

PROJECT STRUCTURE bower_components/

node_modules/ bower.json Commit these files

Gruntfile.js

package.json

Page 14: Sthlm.js 2013: Yeoman workflow

YEOMAN

THE BIG THREE

Page 15: Sthlm.js 2013: Yeoman workflow

YO - WHAT Scaffolding

Opinionated Generators (over 180 available)

Sub-generators

Page 16: Sthlm.js 2013: Yeoman workflow

YO - WHY Automate tedious configuration

Quickly set up a project structure Start with boilerplate code

Perfect if you like starting projects

Page 17: Sthlm.js 2013: Yeoman workflow

YO - HOW

$ npm install -g yo

# will install Bower and Grunt too!

$ npm search yeoman-generator

$ npm install -g generator-angular

~/myproj $ yo angular

Page 18: Sthlm.js 2013: Yeoman workflow

BOWER - WHAT npm for front-end libraries

Dependency-management bower.json (`bower init`)

.bowerrc

Page 19: Sthlm.js 2013: Yeoman workflow

BOWER - WHY It’s a package manager!

Freedom from google+copy+paste Lock version

Distribution

Page 20: Sthlm.js 2013: Yeoman workflow

BOWER - HOW

$ npm install -g bower

~/myproj $ bower init

~/myproj $ bower install jquery --save

# save-flag updates bower.json

Page 21: Sthlm.js 2013: Yeoman workflow

BOWER - HOW

$ npm install -g bower

~/myproj $ bower init

~/myproj $ bower install jquery --save

# save-flag updates bower.json

Yo

Page 22: Sthlm.js 2013: Yeoman workflow

BOWER.JSON

Page 23: Sthlm.js 2013: Yeoman workflow

.BOWERRC

Page 24: Sthlm.js 2013: Yeoman workflow

GRUNT - WHAT JavaScript task runner

Tasks (over 1000 available) Gruntfile.js

package.json (‘npm init’)

Page 25: Sthlm.js 2013: Yeoman workflow

GRUNT - WHY CLI

No more custom Makefiles Over a thousand existing tasks

Unified workflow

Automation

Page 26: Sthlm.js 2013: Yeoman workflow

GRUNT - HOW

$ npm install -g grunt-cli

~\myproj $ npm init

~\myproj $ npm install grunt --save-dev

# save flag updates package.json

~\myproj $ npm install grunt-contrib-qunit --save-dev

~\myproj $ grunt

Page 27: Sthlm.js 2013: Yeoman workflow

GRUNT - HOW

$ sudo npm install -g grunt-cli

~\myproj $ npm init

~\myproj $ npm install grunt --save-dev

# requires package.json available

~\myproj $ npm install grunt-contrib-qunit --save-dev

~\myproj $ grunt

Yo

Page 28: Sthlm.js 2013: Yeoman workflow

GRUNTFILE.JSON

Page 29: Sthlm.js 2013: Yeoman workflow

DEMO If we had more time…

…we would work backwards.

Page 30: Sthlm.js 2013: Yeoman workflow

YO $ yo

$ yo angular

# Check output log

# Check out structure

$ yo angular:directive myDirective

Page 31: Sthlm.js 2013: Yeoman workflow

GRUNT $ grunt test

$ grunt server

$ grunt build

Page 32: Sthlm.js 2013: Yeoman workflow

BOWER $ bower list

$ bower install underscore –save

$ bower list

Page 33: Sthlm.js 2013: Yeoman workflow

QUESTIONS?