Skip to content

Commit

Permalink
Add support for node 14 and 16, mark older versions legacy (#66)
Browse files Browse the repository at this point in the history
* Add support for node 14 and 16, remove some stone age node configs

* Mark node 12 also as legacy

* Set node 14 as default version for now

* Use a patch version of node that actually exists

* Upgrade dependencies to the most recent for node 14

* Add an example for node16

* Use correct node versions in README

* Add node 16.13 point version

* Add all node tests to github workflow

* Node 16 README should have 16 in header so that leia can generate node16 test

* Make node 16 custom config use node 17 like we do in the test

* Add node 17 to list of supported version so that brave people can work with dev versions of node

* Add node-10-example test back

* Node10 test should use node10 and not the new default node version
  • Loading branch information
badrange authored Nov 23, 2021
1 parent d139cd3 commit 1ea1320
Show file tree
Hide file tree
Showing 24 changed files with 3,539 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pr-node-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ jobs:
node-version:
- '14'
leia-tests:
- node-10-example
- node-16-example
- node-14-example
- node-12-example
- node-10-example
steps:

# Install deps and cache
Expand Down
2 changes: 1 addition & 1 deletion .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ excludes:
- node_modules
services:
cli:
type: node:12
type: node:14
build:
- yarn install
scanner: false
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 12.16.1
nodejs 14.18.1
2 changes: 1 addition & 1 deletion examples/landofile-custom/.solo.dist.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: solo-base
services:
node:
type: node:12
type: node:14
tooling:
node:
service: node
2 changes: 1 addition & 1 deletion examples/node10/.lando.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lando-node-10
services:
defaults:
type: node
type: node:10
build:
- yarn
command: /app/node_modules/.bin/nodemon src/app-http.js --watch src --ignore *.test.js
Expand Down
3 changes: 3 additions & 0 deletions examples/node14/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
*.log
package-lock.json
40 changes: 40 additions & 0 deletions examples/node14/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: lando-node-14
services:
defaults:
type: node:14
build:
- yarn
command: /app/node_modules/.bin/nodemon src/app-http.js --watch src --ignore *.test.js
cli:
type: node
compass:
type: node:14
globals:
grunt-cli: latest
build_as_root:
- apt-get update -y
- apt-get install ruby-full -y
- gem install compass
custom:
type: node:16
ssl: true
globals:
gulp-cli: latest
port: 3000
build:
- yarn
command: /app/node_modules/.bin/nodemon src/app-https.js --watch src --ignore *.test.js
custom2:
type: node:14.18
ssl: 4444
port: 3000
build:
- yarn
command: /app/node_modules/.bin/nodemon src/app-custom.js --watch src --ignore *.test.js
patch:
type: node:14.18.1
tooling:
ruby:
service: compass
compass:
service: compass
91 changes: 91 additions & 0 deletions examples/node14/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Node 14 Example
===============

This example exists primarily to test the following documentation:

* [Node 14-16 Service](https://docs.devwithlando.io/tutorials/node.html)
* [Installing compass in your node service](https://docs.lando.dev/guides/using-compass-on-a-lando-node-service.html)

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should start up successfully
lando poweroff
lando start
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should use 14.x as the default version
lando ssh -s defaults -c "env | grep NODE_VERSION=14."

# Should use a user specified version if given
lando ssh -s custom -c "env | grep NODE_VERSION=16."

# Should use a user specified patch version if given
lando ssh -s patch -c "env | grep NODE_VERSION=14.18.1"

# Should serve over port 80 by default
lando ssh -s defaults -c "curl http://localhost | grep tune"

# Should set NODE_EXTRA_CA_CERTS with lando domain CA
lando ssh -s defaults -c \'env | grep NODE_EXTRA_CA_CERTS | grep "$LANDO_CA_CERT"\'

# Should only serve over http by default
lando ssh -s defaults -c "curl https://localhost" || echo $? | grep 1

# Should serve over specified ports if given
lando ssh -s custom -c "curl http://localhost:3000 | grep tune"

# Should serve over https is ssl is set by user
lando ssh -s custom -c "curl https://localhost | grep tune"

# Should servce over a custom https port if ssl is set to a specific port
lando ssh -s custom2 -c "curl https://localhost:4444 | grep DANCING"

# Should run as root if it needs to
lando ssh -s defaults -c "ps -a -u root" | grep "node" | wc -l | grep 2
lando ssh -s defaults -c "ls -lsa /certs" | grep "root root" | wc -l | grep 10
lando ssh -s custom -c "ps -a -u root" | grep "node" | wc -l | grep 2
lando ssh -s custom -c "ls -lsa /certs" | grep "root root" | wc -l | grep 10

# Should run as node if it can
lando ssh -s custom2 -c "ps -a -u node" | grep "node" | wc -l | grep 2
lando ssh -s custom2 -c "ls -lsa /certs" | grep "node" | wc -l | grep 8

# Should install global dependencies if specified by user and have them available in PATH
lando ssh -s custom -c "gulp -v"
lando ssh -s custom -c "which gulp | grep /var/www/.npm-global"

# Should PATH prefer node dependency binaries installed in /app/node_modules over global ones
lando ssh -s custom -c "npm install gulp-cli --no-save"
lando ssh -s custom -c "gulp -v"
lando ssh -s custom -c "which gulp | grep /app/node_modules/.bin"
lando ssh -s custom -c "npm uninstall gulp-cli"
lando ssh -s custom -c "which gulp | grep /var/www/.npm-global"

# Should not serve port for cli
lando ssh -s cli -c "curl http://localhost" || echo $? | grep 1

# Should install ruby and compass on the compass service
lando ruby -v
lando compass -v
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
lando destroy -y
lando poweroff
```
27 changes: 27 additions & 0 deletions examples/node14/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "node-lando",
"version": "1.0.0",
"description": "Node example for Lando",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/lando/lando/tree/master/examples/node"
},
"keywords": [
"node",
"docker",
"localdev"
],
"author": "Mike Pirog",
"license": "MIT",
"dependencies": {
"express": "^4.15.3"
},
"devDependencies": {
"grunt-contrib-compass": "^1.1.1",
"nodemon": "^2.0.15"
}
}
28 changes: 28 additions & 0 deletions examples/node14/src/app-custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Lando node express example
*
* @name taylorswift
*/

'use strict';

// Load modules
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const app = express();

// Create our HTTPS server options
const key = fs.readFileSync('/certs/cert.key');
const cert = fs.readFileSync('/certs/cert.crt');

// Create our servers
https.createServer({key, cert}, app).listen(4444);
http.createServer(app).listen(3000);

// Basic HTTP response
app.get('/', (req, res) => {
res.header('Content-type', 'text/html');
return res.end('<h1>DANCING DANCING STARLIGHT</h1>');
});
21 changes: 21 additions & 0 deletions examples/node14/src/app-http.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Lando node express example
*
* @name taylorswift
*/

'use strict';

// Load modules
const http = require('http');
const express = require('express');
const app = express();

// Create our server
http.createServer(app).listen(80);

// Basic HTTP response
app.get('/', (req, res) => {
res.header('Content-type', 'text/html');
return res.end('<h1>I said "Oh my!" What a marvelous tune!!!</h1>');
});
28 changes: 28 additions & 0 deletions examples/node14/src/app-https.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Lando node express example
*
* @name taylorswift
*/

'use strict';

// Load modules
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const app = express();

// Create our HTTPS server options
const key = fs.readFileSync('/certs/cert.key');
const cert = fs.readFileSync('/certs/cert.crt');

// Create our servers
https.createServer({key, cert}, app).listen(443);
http.createServer(app).listen(3000);

// Basic HTTP response
app.get('/', (req, res) => {
res.header('Content-type', 'text/html');
return res.end('<h1>I said "Oh my!" What a marvelous tune!!!</h1>');
});
Loading

0 comments on commit 1ea1320

Please sign in to comment.