The Secrets of The FullStack Ninja - Part A - Session I

122
בוקר טוב

description

A workshop slideshow on client side devop methodology

Transcript of The Secrets of The FullStack Ninja - Part A - Session I

Page 1: The Secrets of The FullStack Ninja - Part A - Session I

בוקר טוב

Page 2: The Secrets of The FullStack Ninja - Part A - Session I

What’s on for today?

A workshop on setting up a web developer environment

Page 3: The Secrets of The FullStack Ninja - Part A - Session I

What you should have already setup

● Installed:node; npm; git; ruby+sass+compass;

IDEA/Sublime.

● GitHub Account that you can push to.

Page 4: The Secrets of The FullStack Ninja - Part A - Session I

The big picture

Fullstack development using standard web technologies

Page 5: The Secrets of The FullStack Ninja - Part A - Session I
Page 6: The Secrets of The FullStack Ninja - Part A - Session I

What’s the stack?

Liveperson stack

Page 7: The Secrets of The FullStack Ninja - Part A - Session I

Just before we start

About me

Page 8: The Secrets of The FullStack Ninja - Part A - Session I

storyboard

GIT

Page 9: The Secrets of The FullStack Ninja - Part A - Session I

storyboard

SPA Server using Node & NPM

Page 10: The Secrets of The FullStack Ninja - Part A - Session I

storyboard

Grunt

Page 11: The Secrets of The FullStack Ninja - Part A - Session I

storyboard

Bower

Page 12: The Secrets of The FullStack Ninja - Part A - Session I

storyboard

web developer toolings

Page 13: The Secrets of The FullStack Ninja - Part A - Session I

storyboard - BONUS

requirejs and it’s optimizer rjs

Page 14: The Secrets of The FullStack Ninja - Part A - Session I

Timetable

10:00 - 11:00 Some Gitting11:00 - 11:30 EXERCISE11:30 - 12:00 SPA Server12:00 - 13:00 LUNCH13:00 - 13:30 SPA Server - continued 13:30 - 14:00 EXERCISE14:00 - 14:30 Grunting

**code along

Page 15: The Secrets of The FullStack Ninja - Part A - Session I

Timetable

14:30 - 15:00 BREAK15:00 - 16:30 EXERCISE16:30 - 17:00 Solution17:00 - 17:30 Bower17:30 - 18:00 Tooling

**code along

Page 16: The Secrets of The FullStack Ninja - Part A - Session I

Let’s Start

Page 17: The Secrets of The FullStack Ninja - Part A - Session I

Why bother Git

Page 18: The Secrets of The FullStack Ninja - Part A - Session I

HAPPYit makes developers

Page 19: The Secrets of The FullStack Ninja - Part A - Session I

no need for server installation just fs

Git is a decentralized vc

Page 20: The Secrets of The FullStack Ninja - Part A - Session I

Git is much faster than Subversion

Page 21: The Secrets of The FullStack Ninja - Part A - Session I

Branch Handling

Page 22: The Secrets of The FullStack Ninja - Part A - Session I

in SVN versioning features depend on commit access

Access Control

Page 23: The Secrets of The FullStack Ninja - Part A - Session I

git can reference different remote repositories all at the same time

SVN is Single Repository

Page 24: The Secrets of The FullStack Ninja - Part A - Session I

Sub Repositories

Page 25: The Secrets of The FullStack Ninja - Part A - Session I

full local control

Page 26: The Secrets of The FullStack Ninja - Part A - Session I

SVN Model

stagingarea

remoterepository

local server

working directory

add

commit

Page 27: The Secrets of The FullStack Ninja - Part A - Session I

GIT Model

stagingarea

remoterepository

local server

working directory

localrepository

add

commit

push

(untracked)

Page 30: The Secrets of The FullStack Ninja - Part A - Session I
Page 31: The Secrets of The FullStack Ninja - Part A - Session I

git files you should be familiar with

Page 32: The Secrets of The FullStack Ninja - Part A - Session I

.gitignore

Page 33: The Secrets of The FullStack Ninja - Part A - Session I

.git directory

Page 34: The Secrets of The FullStack Ninja - Part A - Session I

Create flow

Page 35: The Secrets of The FullStack Ninja - Part A - Session I

one time config

Page 36: The Secrets of The FullStack Ninja - Part A - Session I
Page 37: The Secrets of The FullStack Ninja - Part A - Session I
Page 38: The Secrets of The FullStack Ninja - Part A - Session I

Exercise

Setup a local git repositoryconfigure itadd a README filecommitpush to GitHub

20min

Page 39: The Secrets of The FullStack Ninja - Part A - Session I

Software at your aid

mac useriterm2oh-my-zsh

windows userunix tools

Page 40: The Secrets of The FullStack Ninja - Part A - Session I

Node Package Manager

node & NPM

Page 41: The Secrets of The FullStack Ninja - Part A - Session I

with node we’ll run thingswith npm we’ll install things

Page 42: The Secrets of The FullStack Ninja - Part A - Session I

What will we use npm for?

Page 43: The Secrets of The FullStack Ninja - Part A - Session I

system tools

Page 44: The Secrets of The FullStack Ninja - Part A - Session I

project libraries

Page 45: The Secrets of The FullStack Ninja - Part A - Session I

which themselves power many packagesand that we’ll shortly use

powers grunt and bower

Page 46: The Secrets of The FullStack Ninja - Part A - Session I

export PATH=$HOME/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin

make sure you have it set in your path

This way cli modules could be used in terminal

Page 48: The Secrets of The FullStack Ninja - Part A - Session I

Let’s setup our SPA server

Page 49: The Secrets of The FullStack Ninja - Part A - Session I

if fnf return index

Page 50: The Secrets of The FullStack Ninja - Part A - Session I

skips the network

The hash#

Page 51: The Secrets of The FullStack Ninja - Part A - Session I

modifies history urls

History API

Page 52: The Secrets of The FullStack Ninja - Part A - Session I

But still a url path will always turn to the server

Page 53: The Secrets of The FullStack Ninja - Part A - Session I

the downside

SEO and SPA

Page 54: The Secrets of The FullStack Ninja - Part A - Session I

but still not 100%

Google crawlers are now doing better with SPA

Page 55: The Secrets of The FullStack Ninja - Part A - Session I

Blog vs App

To SPA or not to SPA?

Page 56: The Secrets of The FullStack Ninja - Part A - Session I

kudo to JavaScript on the server

cs-fw can run on the server

Page 57: The Secrets of The FullStack Ninja - Part A - Session I

both server-pages and single-paged

Dualism

Page 58: The Secrets of The FullStack Ninja - Part A - Session I

Organize project fs

server paged

spa

Page 59: The Secrets of The FullStack Ninja - Part A - Session I

web application framework for node

Express

Page 60: The Secrets of The FullStack Ninja - Part A - Session I

our first module install

npm install express --save

Page 61: The Secrets of The FullStack Ninja - Part A - Session I

serving static content

Page 62: The Secrets of The FullStack Ninja - Part A - Session I

distinguishing between environments

production vs development

Page 63: The Secrets of The FullStack Ninja - Part A - Session I

serving the same file

Page 64: The Secrets of The FullStack Ninja - Part A - Session I
Page 65: The Secrets of The FullStack Ninja - Part A - Session I

$ node server.js

run server

Page 66: The Secrets of The FullStack Ninja - Part A - Session I
Page 67: The Secrets of The FullStack Ninja - Part A - Session I

Exercise

install expressjssetup server.jsshow both resource pathand redirect to index

20min

Page 68: The Secrets of The FullStack Ninja - Part A - Session I

The JavaScript Task RunnerGRUNT

Page 69: The Secrets of The FullStack Ninja - Part A - Session I

what will it be used for?

Page 70: The Secrets of The FullStack Ninja - Part A - Session I

packaging a release dist

Page 71: The Secrets of The FullStack Ninja - Part A - Session I
Page 72: The Secrets of The FullStack Ninja - Part A - Session I

aiding development

Page 73: The Secrets of The FullStack Ninja - Part A - Session I
Page 74: The Secrets of The FullStack Ninja - Part A - Session I

and counting

over 3,453 plugins

Page 75: The Secrets of The FullStack Ninja - Part A - Session I

npm install -g grunt-cli

you’ll need the cli

Page 76: The Secrets of The FullStack Ninja - Part A - Session I

npm install grunt --save-dev

you’ll also need it in your project

Page 77: The Secrets of The FullStack Ninja - Part A - Session I

we need to write it ourselves?

all we need is Gruntfile.js

Page 79: The Secrets of The FullStack Ninja - Part A - Session I

$ grunt-init gruntfile

Page 80: The Secrets of The FullStack Ninja - Part A - Session I

FileStructure

config

load

register

Page 81: The Secrets of The FullStack Ninja - Part A - Session I

load-grunt-tasksmodule

can save us having to explicitlyload the npm task

but!

Page 82: The Secrets of The FullStack Ninja - Part A - Session I

pkg.titleconcat.dist.dest

Datafrom

within

Page 84: The Secrets of The FullStack Ninja - Part A - Session I

^(major) ~(minor) 1.0.x(patch)*/latest(latest)

major.minor.patch

Page 85: The Secrets of The FullStack Ninja - Part A - Session I

More

"<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0""git://github.com/flatiron/winston#master"

Page 86: The Secrets of The FullStack Ninja - Part A - Session I

Version

Management

cli plugin

Page 87: The Secrets of The FullStack Ninja - Part A - Session I
Page 88: The Secrets of The FullStack Ninja - Part A - Session I
Page 89: The Secrets of The FullStack Ninja - Part A - Session I

The Grunt Recipe

Page 91: The Secrets of The FullStack Ninja - Part A - Session I

Solution

Page 92: The Secrets of The FullStack Ninja - Part A - Session I

A package manager for the web

Bower

“and peace shall come upon us”

Page 93: The Secrets of The FullStack Ninja - Part A - Session I

npm install -g bower

it’s just another node package

Page 94: The Secrets of The FullStack Ninja - Part A - Session I

resembles npm syntax

Page 95: The Secrets of The FullStack Ninja - Part A - Session I

bower_components is to bower as

node_modules is to npm

Page 96: The Secrets of The FullStack Ninja - Part A - Session I

generates bower.json

bower init

Page 97: The Secrets of The FullStack Ninja - Part A - Session I

bower search <package>

search for componentsover 17,583 of them

Page 98: The Secrets of The FullStack Ninja - Part A - Session I

bower install -p

Do not install project devDependencies

Page 100: The Secrets of The FullStack Ninja - Part A - Session I

{"directory" : "public/bower_components"

}

let’s move cs libs to server root

Page 101: The Secrets of The FullStack Ninja - Part A - Session I

What we’ll need:

Page 103: The Secrets of The FullStack Ninja - Part A - Session I

Developers Toolbox

Page 104: The Secrets of The FullStack Ninja - Part A - Session I

why not IDEA?

Sublime IDE

Page 105: The Secrets of The FullStack Ninja - Part A - Session I

Good enough reasons

1. biggest plugin ecosystem (Package Control)2. multiple cursors3. shortcuts like move-lines actually work4. lightweight and fast

Page 106: The Secrets of The FullStack Ninja - Part A - Session I

All this for just

1 license: USD $7010+ licenses: USD $60 / license25+ licenses: USD $55 / license50+ licenses: USD $50 / license

Page 108: The Secrets of The FullStack Ninja - Part A - Session I

no full page refresh on edit

livereload

Page 109: The Secrets of The FullStack Ninja - Part A - Session I

taglet or browser extension

Page 110: The Secrets of The FullStack Ninja - Part A - Session I

edit sass directly through devtool

css sourcemaps

Page 111: The Secrets of The FullStack Ninja - Part A - Session I

gem install compass --pre

compass alpha version

Page 112: The Secrets of The FullStack Ninja - Part A - Session I

gem update sass

don’t forget to update sass gem

Page 113: The Secrets of The FullStack Ninja - Part A - Session I

Chrome DevTool filesystem support

browser support

Page 114: The Secrets of The FullStack Ninja - Part A - Session I

diff your devtool styling session

livestyle

Page 115: The Secrets of The FullStack Ninja - Part A - Session I

Exercise

use css sourcemaps along with livereload and devtool fs supportto modify in chrome devtool sass files

ex

1h

Page 116: The Secrets of The FullStack Ninja - Part A - Session I

how they differ?

requirejs and r.js

Page 117: The Secrets of The FullStack Ninja - Part A - Session I

grunt-requirejs or grunt-contrib-requirejs

delivered through Grunt

Page 118: The Secrets of The FullStack Ninja - Part A - Session I

path, shim and all the others

require config

Page 120: The Secrets of The FullStack Ninja - Part A - Session I

include vs

findNestedDependencies