@MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt,...

56
4th of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers #SPSMUC05

Transcript of @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt,...

Page 1: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

4th of March 2017

@MS HQ Munich

Git,

Gulp, Grunt,

Node and Code:Making Sense of the

Modern Development Toolchain

Bill Ayers #SPSMUC05

Page 2: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...
Page 3: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Bill Ayers

MCM/MCSM Charter SharePoint

Email: [email protected]

Blog: www.SPDoctor.com

Twitter: @SPDoctor

MCT, MVP, MCTS, MCITP, MCSD, MCAD, MCSA,

MCDBA, MSc, MInstE etc.

– Flow Simulation Ltd.

– www.SPDoctor.net

[email protected]

– @SPDoctor

– Consultant specialising in SharePoint and Office 365 Development and Architecture for Collaboration and Mobile Development

Page 4: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Agenda

• What is 'modern’?

• Node

• Grunt and Gulp

• Git

• Code

• Yeoman

• JavaScript Revisited

• Angular and React

• Office UI Fabric

• Conclusions

Page 5: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

What is “modern”?

root:>

Page 6: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

The Rise of Client-side Technologies• JavaScript

• jQuery

• AJAX

• HTML5

• CSS3

• JavaScript Libraries: React, Angular, etc.

• Node.js

• REST/OData/OAuth

Page 7: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Motivation

• End User Expectations– Rich behaviour in web applications

– “Web 2.0” experience

– Modern Apps

– Mobile (any device, anywhere)

• Microsoft– Custom code is source of many support issues

– Custom code prevents migration to new versions

– Custom code not supported on Office 365

– Make accessible to web developers…

Page 8: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Opening up to web developers

“Use your existing skills to build apps and

take advantage of familiar tools, languages,

and hosting services. You can use any

language, such as HTML, JavaScript, PHP,

or .NET, and you can use your favorite web

development tools”

MSDN

App

Page 9: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Introducing the SharePoint Framework (SPFx)

• Model for building client-side pages and web parts

• Announced May 4th 2016, now GA!

• Authoring canvas, no iFrames

• Command-line-driven open-source toolchain

• Used by SharePoint product team

• Works in “modern” and “classic” pages

• Your choice of client-side framework; Angular, React,

Knockout, Vanilla.JS ;-)

Wait, did you say “Command-

line-driven open-source

toolchain” ?

Page 10: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Logo Quiz

Page 11: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Node.jsJavaScript on the server????

Page 12: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Node.js

• Server-side JavaScript

• Uses Google’s V8 engine

• Main use case is as a web server

• Secondary use as part of development environment

• Modular packages

• Go to nodejs.org and follow instructions (2 mins)

• Verify installed by typing node --version at

command prompt

Page 13: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

NPM

• Similar to NuGet

• Manages dependencies

• npm install

• NPM install is driven by package.json

• For Windows, make sure you have version 3

• -g option to install globally

• npm install packagename

• npm init in new directory creates package.json

Page 14: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Node

Page 15: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Grunt and GulpLike “make” or “nant”, but cooler…

Page 16: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Grunt: JavaScript Build Engine

• like a traditional make command (e.g. Unix make or

msbuild)

• makefile replaced by JSON

• install the command line tool…

• npm install -g grunt-cli

Page 17: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Gulp: JavaScript Build Engine

• Build tasks defined in JavaScript

• Gulpfile.js runs build process

• In gulpfile.js, define tasks…

var gulp = require('gulp.js');gulp.task('taskname', function() {// do Stuff here

});

• Streaming model, a bit like Unix pipes

• Gulp tasks for SASS, TypeScript, etc. etc.

• gulp.watch('*.scss', ['task1','task2']);

Page 18: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Installing Gulp

• npm install –g gulp

• Create a directory

• npm install gulp --save-dev

• Create gulpfile.js

• gulp --help

• gulp --tasks

Page 19: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

"devDependencies": { "gulp": "^3.8.11", "gulp-debug": "^2.0.1", "gulp-inject": "^1.2.0", "gulp-sourcemaps": "^1.5.1", "gulp-tslint": "^1.4.4", "gulp-typescript": "^2.5.0", "gulp-rimraf": "^0.1.1"

}

Suggested Dependencies (package.json)

Dan Wahlin

Page 20: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

var gulp = require('gulp');var pug = require('gulp-pug');var less = require('gulp-less');var minifyCSS = require('gulp-csso');

gulp.task('html', function(){return gulp.src('client/templates/*.pug').pipe(pug()).pipe(gulp.dest('build/html'))

});

gulp.task('css', function(){return gulp.src('client/templates/*.less').pipe(less()).pipe(minifyCSS()).pipe(gulp.dest('build/css'))

});

gulp.task('default', [ 'html', 'css' ]);

gulp.watch('*.scss', ['task1','task2']);

gulpfile.js

Page 21: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Git(and GitHub)

Page 22: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Distributed Source Control with Git

• No real “master” or server

• Command-line

• GUI tools available

Page 23: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

• Install from git-scm.com

Installing Git

Page 24: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

GitHub

Page 25: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Visual Studio CodeFaster, lighter, leaner, meaner…

Page 26: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Visual Studio• Probably the best development environment on the planet

• With awesome power comes…. A lot of waiting! (and that’s with an SSD)

• Visual Studio Code is a lightweight editor, but it does more than you might think…

*also available

in dark

Page 27: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Installing VS Code

• To install Visual Studio Code, go to

http://code.visualstudio.com/, download and install.

• only takes a few minutes

• knows about package managers

• add-ons for things like Yeoman

Page 28: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Visual Studio Code

Page 29: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

What’s missing?

• …file->new->project

Page 30: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Yeoman

It’s just “File New Project”…

Page 31: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Scaffolding

• A bit like the File->New->Project

• A lot more people writing Yeoman generators

• npm install –g yeoman

• npm install –g generator-xyz

• yo (list of generators and commands)

• yo office, yo angular, etc. etc.

Page 32: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

JavaScript Revisited

It’s not what you think…

Page 33: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Just the Good Parts, Please!

• Not like C, C++, C#, Java

• Prototypal inheritance

• TypeScript

• ES2015 aka ES6

• A beautifully designed functional language,

with a few very serious mistakes

Page 34: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Encapsulation patterns

mynamespace = mynamespace || {};

mynamespace.foo = {name: “name”,value: “bar”,doSomething: function() {

..do stuff};

};

mynamespace.mymodule = function() {var privateValue;var doSomething: function() {..do stuff

};return {doStuff: doSomething

}}();

Page 35: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

TypeScript

• Features of next version of JavaScript

• Compiles to JavaScript

• Features of next version of JavaScript

• Compiles to JavaScript

• Strong typing, classes

• Original design goal was to make JavaScript easier for

C# developers

• Makes it easier to write production quality JavaScript

• Good support in VS Code

Page 36: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Angular and React

Page 37: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Questions

• What are my existing skills - can I re-use?

• What is my existing code - can I re-use?

• What platforms do I need to support?

• What level of legacy platform version needed? (caniuse.com)

• Who is backing different frameworks?

• How much support can you expect?

• What does it give me?

• How opinionated is it?

Page 38: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Angular• Backed by Google

• Very popular because it gives a complete SPA

framework

• Very opinionated, but in some ways this can be an

advantage

• Angular 2 follows more of a web component model

at the cost of backward compatibility

• Learn more: go to angularjs.org

Page 39: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

ReactJS

• Backed by Facebook and Instagram

• Virtual DOM page rendering model

• Very fast

• Provides the view engine only

• JSX format takes some getting used to

• TypeScript Compiler has support for JSX

• ReactJS tutorial: https://zapier.com/engineering/react-

js-tutorial-guide-gotchas/

Page 40: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Vanilla.js – the latest trending framework?

Page 41: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Looking at ReactJS

Page 42: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Office UI Fabric

A responsive framework, kind of…

Page 43: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Office UI Fabric• Intended for developing Office Add-ins

• Consistent look-and-feel with Office

• Sort of a responsive framework

• About 100k, 200k with components

• Not originally aligned with “classic” SharePoint CSS, but SharePoint is

changing with “modern” sites and SPFx

• Available as raw CSS or versions for Angular and React

• Dev.office.com/fabric

Page 44: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Office UI Fabric• Design elements to give add-ins the same look

and feel as the rest of the Office suite

• Consistent typography, icons and behaviour

Link to UI Fabric Stylesheets:<link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.2.0/fabric.min.css"> <link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.2.0/fabric.components.min.css">

Decorate elements with UI Fabric classes:<button class="ms-Button" id="get-data-from-selection"> <span class="ms-Button-icon"><em class="ms-Icon ms-Icon--plus"></em></span> <span class="ms-Button-label">Get Data from selection</span> <span class="ms-Button-description">Get Data from the document selection</span> </button>

http://dev.office.com/fabric

Link to UI Fabric JS:<script src="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.2.0/js/fabric.min.js"></script>

Page 45: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Office UI Fabric ReactJS Components

• 30 React components, ready to use

• Used by Microsoft to build Office and SharePoint

• Angular? See ngOfficeUIFabric

<fabric.Button onClick={() => this.getData() } className="ms-Button--primary">Refresh List</fabric.Button>

Breadcrumb

Button

Callout

Checkbox

ChoiceGroup

ColorPicker

CommandBar

ContextualMenu

DatePicker

DetailsList

Dialog

DocumentCard

Dropdown

Facepile

GroupedList

Image

Label

Layer

Link

List

MessageBar

Nav

Overlay

Panel

Persona

Pickers

PeoplePicker

Pivot

ProgressIndicator

SearchBox

Slider

Spinner

TextField

Toggle

Page 46: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Looking at Office UI Fabric

Page 47: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Office Dev PnP

Sharing is Caring…

Page 48: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Looking at OfficeDev PnP JS-Core

Page 49: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

SPFxThe SharePoint Framework

Page 50: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Introducing the SharePoint Framework (SPFx)

Page 51: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...
Page 52: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Building an SPFx WebPart

Page 53: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Health Alert: Chasing Unicorns

can seriously damage your wealth

You can waste a huge amount of

time and resources trying to come

up with a universal development

solution

#UnicornsWithSmartphones

Page 54: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Conclusions

• We can re-use (or re-learn) our JavaScript skills pretty much everywhere

• New Microsoft loves open-source toolsets

• It’s not Microsoft’s job to tell you how to code, or what tools to use, but it’s interesting to see what tools THEY are using

• You don’t HAVE to use VS Code, etc. – you can continue to use Visual Studio, Add-ins, FTC on-prem, etc…

• Changing fast – need to be agile

Page 55: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Resources:

Bingle

• http://dev.office.com/SharePoint

• http://dev.office.com/fabric

• https://facebook.github.io/react/

• http://github.com/officedev/trainingcontent

• https://dev.office.com/training

• https://github.com/SharePoint/PnP-JS-Core

• http://github.com/SPDoctor/SPFXShoppingList

Page 56: @MS HQ Munich Git, Gulp, Grunt, Node and Code - … of March 2017 @MS HQ Munich Git, Gulp, Grunt, Node and Code: Making Sense of the Modern Development Toolchain Bill Ayers # ...

Thank you!