Wednesday, July 1, 2015

A Basic Outline For NodeJS Rapid Development

I have intentionally veered away from web development work. This is due to some preconceived notions about the market and talent. The basic nay saying sounded like this: there is too much abstraction to understand web code, the learning curve is too steep in modern web development, there are already too many talented Java/.Net web developers out there to compete with, etc. My is really forcing me to rethink what lines I should draw for myself. A good way to break down some of that lack of knowledge seems to be learning the Node JS ecosystem (ie MEAN stack). It has been tons of fun so far.

Here is a set of notes I am using to learn the different templating engines available for scaffolding a new Node project. This is based on a windows work environment. I can already see how ramping up a templated site to allow for D3 on Angular visualizations is a great entry point for any BI project. Since it is all java script some of the IoC and MVC pattern abstractions that make C# code hard to read become far less indirect (at least to me so far). Also, everything has a cute name.

notes:


//install node  I used
Write-host "install node globally" -foreground "Darkcyan"
choco install node
npm --update
Write-host "install express globally" -foreground "DarkCyan"
npm install -g express
Write-host "install node-inspector debugger globally" -foreground "DarkCyan"
npm install -g node-inspector
Write-host "install yeoman app templating globally" -foreground "DarkCyan"npm install -g yo
Write-host "install daemon to monitor changes to your node site globally" -foreground "Darkcyan"
npm install -g nodemon
Write-host "install grunt gulp and bowerbuild support globally" -foreground "Darkcyan"
npm install -g bower grunt-cli gulp
Write-host "install express site templating generator. Sort of sucks but oh well. You can extend it with Hogan for logicless templates or ejs/jade for logic supporting templates" -foreground "darkcyan"
npm install -g express-generator
Write-host "install hottowel app templating generator." -foreground "darkcyan"
npm install -g generator-hottowel

/*
-h, --help          output usage information
-V, --version       output the version number
-e, --ejs           add ejs engine support (defaults to jade)
    --hbs           add handlebars engine support
-H, --hogan         add hogan.js engine support
-c, --css <engine>  add stylesheet <engine> support (less|stylus|compass) (defaults to plain css)
    --git           add .gitignore
-f, --force         force on non-empty directory
*/


//change to root source dir

express AppName  -t hogan -c less ; cd AppName; npm install;pwd; ls;
if (Test-Path node_modules){write-host "node-modules found"} else {write-host "node-modules not found. did you do npm install as root?"}
more .\package.json;.\bin\www

//change the second line in bin\www appName:server to just app (matching the app.js in root dir)
//add a Gruntfile.js
New-Item Gruntfile.js -ItemType file

//start Node CLI repl
node --debug

//start an inspector
node-inspector
//open a chrome tab to the posted URL

//Run site in Debug
SET DEBUG=App:* ; npm start

//open chrome brownser to url and port in bin/www settings
http://127.0.0.1:3000/

//run app
node ./bin/www
//or maybe
npm start

//or let's try creating a new app using hottowel
mkdir yoApp
cd yoApp
yo hottowel helloWorld
//another way to start an app
gulp serve-dev --sync
///////////////////////////////////
//To run site in Debug
SET DEBUG=App:* ; npm start

//open chrome brownser to url and port in bin/www settings
http://127.0.0.1:3000/

//run app
node ./bin/www

//or maybe
npm start

//or let's try creating a new app using hottowel
mkdir yoApp
cd yoApp
yo hottowel helloWorld
//another way to start an app
gulp serve-dev --sync

# uninstall commands
$NodeInstallPath  = cmd /c where node
$NpmInstallPath  = cmd /c where npm;if($NpmInstallPath.Count -gt 1){$NpmInstallPath = $NpmInstallPath[0]}


$AppData = Get-Childitem env:APPDATA | %{ $_.Value }
$userconfig       = npm config get -g -Filter userconfig
$globalconfig     = npm config get -g -Filter globalconfig
$globalignorefile = npm config get -g -Filter globalignorefile
$cache            = npm config get -g -Filter cache
$prefix           = npm config get -g -Filter prefix

if (test-path $globalconfig){
    write-host -foreground "cyan" "cleaning out $globalconfig"
    rmdir -force -recurse $globalconfig}
if (test-path $userconfig){
    write-host -foreground "cyan" "cleaning out $userconfig"
    rmdir -force -recurse $userconfig}
if (test-path $globalignorefile){
    write-host -foreground "cyan" "cleaning out $globalignorefile"
    rmdir -force -recurse $globalignorefile}
if (test-path $cache){
    write-host -foreground "cyan" "cleaning out $cache"
    rmdir -force -recurse $cache}
if (test-path $prefix){
    write-host -foreground "cyan" "cleaning out $prefix"
    rmdir -force -recurse $prefix}
if (test-path $NodeInstallPath){
    write-host -foreground "cyan" "cleaning out $NodeInstallPath"
    choco uninstall nodejs}

No comments:

Post a Comment