salvatore rinzivillo visual analyticsdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfuse...

31
VISUAL ANALYTICS Salvatore Rinzivillo

Upload: others

Post on 13-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

VISUALANALYTICSSalvatoreRinzivillo

Page 2: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

DEVELOPMENTFRAMEWORK

Page 3: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Objectives

§  Setupadevelopingenvironment§  InstallNode.jsandNPM§  InstallandconfigureVueandvue-cli§  Configureandinitializeaproject

§  Installandconfiguregit§  Createarepositoryandimportprojectfiles

§  IDEs§  Fork,GitDesktop§ WebStorm,Atom.io,Textmate

Page 4: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Node.jsandNPM

Page 5: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

WhatisNode.js

§  “AnasynchronouseventdrivenJavascriptruntime”§  Non-blocking,event-drivenI/Ooperations

§  Lightweightandefficientfordata-intensiveapplications

§  Distributedcomputationandloadbalancing

§  Availablefordownloadathttps://nodejs.org/

Imagesource:https://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js

Page 6: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

NPM–NodePackageManager

§  Node.jshasalargelibraryofpublicavailable,reusablecomponents

§  Componentsareavailablethrougharepository

§ Managelibrariesforglobaluseandlocalprojects

§  Handlealldependencies

Page 7: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

NPM-Commands

§  npminit§  Initializeaproject,creatingafilepackage.json

§  npminstall<module>§  Downloadandinstallmodulewithinthedirectorynode_modules

§ Withtheflag--save,addthemoduletothepackage.jsonlistofdependencies

§ Withtheflag--global(or-g)themoduleisinstalledgloballyonthesystem

Page 8: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Mostusedpackages

§  Express:awebapplicationdevelopmentframeworkfornode.js

§  Lodash:generalutilitiesforhandlingdatastructuresinjavascript

§  http-server§  Specificallyforthecourse:

§  D3§  Plotly.js§  Bootstrap§  Vue.js§  …

Page 9: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Exercise–CreateaprojectwithNode.js

§  Demo

Page 10: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

CONFIGURINGVUE.JSANDVUE-CLI

Page 11: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

§  npminstall–gvue-cli§  CreateacommandtomanageVue.jsprojects

§  vueinitsimplemy-project§  cdmy-project§  npminstall§  npmrundev§  ThesecommandscreateaskeletonprojectconfiguredwithVue.js

Page 12: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Webserver

Page 13: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

WebServerforNode.js

Page 14: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

WebServerinNode.js

§  Thereareseveralmodulesavailableforrunningawebserver

§  Averysimplehttpserver:§  npminstall-ghttp-server

§  Amoresophisticatedapplicationserver:§  npminstall-gexpress

Page 15: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Exercise–Usehttp-servertoaccessourproject

§  Demo

Page 16: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

VersionControlwithGIT

Page 17: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

WhatisVersionControl?

ImageSource:https://www.git-tower.com/learn/git/ebook/en/command-line/basics/what-is-version-control

Page 18: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

WhyUseaVersionControlSystem?

§  Collaboration§  Anymemberofateamcanworkonanyfileatanytime§  MergeofcontributionishandlebytheVCS

§  Storingversions§  Trackingofchangesthroughperiodicsavesofsnapshots§  Onlyoneversionofaprojectatanytime

§  OtherversionsarepackedwithintheVCS§  Restorepreviousversions§  Followthedevelopmentoftheproject§  Backup,whenusingexternalrepositories

Page 19: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

WhichVCS?IntroducingGIT

§  Downloadaclientfrompublicrepositories§  Forexample:GITHub,BitBucket

§  UseclientsspecificforyourOS§  Forexample:brewinstallgit(forMacOsX)

§  Initialconfiguration§  gitconfig--globaluser.name“rinziv”§  gitconfig--globaluser.email“[email protected]”§  gitconfig--global

Page 20: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

GIT–CreatingaRepository

§  GIThandlestwokindsofrepositories§  Localrepository

§ Containedwithinafolder.gitintherootoftheprojectfolder

§ Onlyonpersonaccessthisrepo§  Remoterepository

§  Locatedintoaremoteserver§  Locallystoredwithinthe.gitfolder§  Teammembersworkconcurrentlyonremoterepository

Page 21: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

GIT–Createalocalrepository

§  Movewithintheprojectrootdirectory§  Usegitinittostartversioningtracking§  Therootoftheprojectiscalledworkingcopy

§  Thereisonlyoneworkingcopyatanymoment§  Itispossibletoupdatethecurrentworkingcopywithpreviousversionsfromtherepository

§  Somefiles(usuallyrelatedtotheOS)canbeignoredfortheversioning§  Createafilecalled.gitignoreintherootoftheprojectfolder

§  Listthefilestoignorewithinthefile

Page 22: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

GIT–Clonearemoterepository

§  AremoterepositoryhaveaURLoftheform:§  ssh://user@server/git-repo.git§  user@server:git-repo.git§  http://example.com/git-repo.git§  https://example.com/git-repo.git§  git://example.com/git-repo.git

Page 23: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

GIT-Commit

§  Commitoperationsavethesnapshotoftheworkingcopyontherepository§  gitadd–A§  gitcommit–m“Initialcommit”

Page 24: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

GIT–Statusoftheproject

§  Eachfilewithintheprojecthaveoneofthefollowingstate§  Untracked:thefileisnotunderversioncontrol.GITdonottrackanychangeonthisfile

§  Tracked:GITreportschangesonthesefiles§  gitstatusreportsthelistoffileswithintheprojectthathavechangedandthosethatarenottracked

Page 25: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

GIT–StagingArea

ImageSource:https://www.git-tower.com/learn/git/ebook/en/command-line/basics/working-on-your-project#start

Page 26: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

GIT–Preparingthestagingareaandcommit

§  Addthefilestoincludeinthestagingarea§  gitaddnew-page.htmlindex.htmlcss/*§  gitrmerror.html§  Checkthestatuswith:gitstatus

§  Commitchanges§  gitcommit-m"Implementthenewloginbox”

Page 27: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Whentocommit?

§  Eachcommitshouldcontainschangesrelatedtoasingletopic

§  Saveonlycompletedwork(fortemporarysavinguseStash)

§  Testtheprojectbeforecommitting§  Adddescriptivemessage§  Commitoften

Page 28: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

DesktopGUIVersion

Page 29: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Fork

https://git-fork.com

Page 30: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

Exercise–Createarepositoryforourproject

§  Demo

Page 31: Salvatore Rinzivillo VISUAL ANALYTICSdidawiki.cli.di.unipi.it/.../va_lesson2_nodejs_npm_git.pdfUse git init to start versioning tracking The root of the project is called working copy

ClassroomSpring2020repositoryhttps://github.com/va602aa-2020