Skip to content

Instantly share code, notes, and snippets.

@mkelandis
mkelandis / node-block-sample.groovy
Created April 18, 2020 13:29
Sample usage for nodeBlock.groovy
stage('Seed') {
env.PATH = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:${env.PATH}"
dir('bqp') {
nodeBlock {
echo 'Running Seed...'
sh 'set -o pipefail && npm run seed'
}
}
}
@mkelandis
mkelandis / node-block.groovy
Last active April 18, 2020 13:26
groovy script used by jenkins pipeline to run node commands with the LTS version
// Template for NodeJs Blocks
def call(Closure body) {
// find the version of nodejs from .nvmrc or default to lts/*
if (!env.NODE_VERSION) {
PWD = sh (
script: "pwd",
returnStdout: true
).trim()
echo "${PWD}" + '/.nvmrc'
@mkelandis
mkelandis / node-dependency-a.sh
Created April 18, 2020 12:49
Output from npm run upgrade:check-lts
$ npm run upgrade:check-lts
> myapp@0.0.1 upgrade:check-lts .../repos/git/myapp
> npm install -g --dry-run node@lts | node bin/nodeLtsCheck.js
Checking for Node LTS: 12.16.2 ...
LTS Version 12.16.2 does not match .nvmrc: 12.16.1
npm ERR! code ELIFECYCLE
@mkelandis
mkelandis / package-check-lts-snippet.json
Created April 18, 2020 12:44
package.json snippet showing upgrade:check-lts
{
"upgrade:check-lts": "npm i -g --dry-run node@lts | node bin/nodeLtsCheck.js",
"ci:branch": "run-s ... upgrade:check-lts",
}
@mkelandis
mkelandis / nodeLtsCheck.js
Created April 18, 2020 12:23
bin/nodeLtsCheck.js returns with a non-zero status when parsed LTS Node version is different from .nvmrc
const fs = require('fs');
function getNvmVersion() {
return fs.readFileSync('.nvmrc').toString().trim();
}
/**
* Run with:
* $ npm install -g --dry-run node@lts | node bin/nodeLtsCheck
*/
$ npm run upgrade:check-dep
...
> npm outdated | node bin/outdatedCheck.js
Package Current Wanted Latest Location
@sendgrid/mail 6.5.5 6.5.5 7.0.0 myapp
@types/express 4.17.3 4.17.3 4.17.6 myapp
@types/jest 25.1.4 25.1.4 25.2.1 myapp
@types/node 13.9.1 13.9.1 13.11.1 myapp
@mkelandis
mkelandis / outdatedCheck.js
Created April 11, 2020 13:05
This code parses the input, assembles two reports (minor, major), radiates them and then exits with an error code if we have any outdated minor dependencies.
/**
* Usage:
* $npm outdated | node bin/outdatedCheck.js
*/
function outdatedCheck() {
const readline = require('readline');
const ioProcessor = readline.createInterface({
input: process.stdin,
output: process.stdout,
@mkelandis
mkelandis / ansible-notes.md
Last active April 19, 2017 11:59
AnsibleNotes

Ansible Notes

Users

  • The default CentOS7 docker image enables root connectivity by default.
  • The default CentOS7 AWS AMI is typically accessed via ssh using the centos user and a .pem file. (Requiring sudo to perform privileged operations on the CLI).
  • The Ansible playbook needs privileged access (root) to perform provisioning.
  • Ansible provides a --become option in order to perform privileged tasks.
  • Providing --become when running the playbook on the CLI for the AMI enironment was the simplest solution.
@mkelandis
mkelandis / noglob.md
Last active April 11, 2017 12:13
Bypass Interceptor Global Error Handling in Angular

The Problem:

A Solution:

  • add a function to the config which decides if the response can be ignored globally

Example:

@mkelandis
mkelandis / macos.md
Last active March 3, 2017 02:22
Setting up mac os x for development.

Brew:

Git:

$ brew install git
$ mkdir ~/repos; mkdir ~/repos/git