diff --git a/package-lock.json b/package-lock.json index 193330cf..dedf23d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -903,7 +903,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -922,7 +922,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -10025,7 +10025,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -11826,7 +11826,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -11908,9 +11908,27 @@ "dev": true }, "yaml": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.3.2.tgz", - "integrity": "sha512-ZZZIdcApMRcAez37EVrtCim+8JUESX0zRcsv+HMfatIX79cX22CAnVkxDrZhAmzsnka2nb/mvaTybzDYcnrIew==" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.4.0.tgz", + "integrity": "sha512-rzU83hGJrNgyT7OE2mP/SILeZxEMRJ0mza0n4KFtkNL1aXUZ79ZgZ5pIH56yT6LiqujcAs/Rqzp0ApvvNYfUfw==", + "requires": { + "@babel/runtime": "^7.3.4" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.3.4.tgz", + "integrity": "sha512-IvfvnMdSaLBateu0jfsYIpZTxAc2cKEXEMiezGGN75QcBcecDUKd3PgLAncT0oOgxKy8dd8hrJKj9MfzgfZd6g==", + "requires": { + "regenerator-runtime": "^0.12.0" + } + }, + "regenerator-runtime": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", + "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" + } + } }, "yargs": { "version": "12.0.1", diff --git a/package.json b/package.json index 3490270e..58f13bfc 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "uri-js": "^4.2.2", "uuid": "^3.3.2", "winston": "^3.1.0", - "yaml": "1.3.2" + "yaml": "1.4.0" }, "devDependencies": { "@adobe/jsonschema2md": "^1.1.1-SNAPSHOT.236", diff --git a/test/config.test.js b/test/config.test.js index 5a9de01d..32ff31cf 100644 --- a/test/config.test.js +++ b/test/config.test.js @@ -66,6 +66,11 @@ data.strains['no-default'] should NOT have additional properties, data.strains[' config: 'perf.yaml', result: 'perf.json', }, + { + title: 'loads config with comments', + config: 'various_comments.yaml', + result: 'comments.json', + }, ]; describe('Helix Config Loading', () => { diff --git a/test/specs/configs/comments.json b/test/specs/configs/comments.json new file mode 100644 index 00000000..c4fad0ff --- /dev/null +++ b/test/specs/configs/comments.json @@ -0,0 +1,197 @@ +{ + "strains": { + "adhoc": { + "code": { + "host": "github.com", + "hostname": "github.com", + "owner": "adobe", + "path": "", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "condition": "", + "content": { + "host": "github.com", + "hostname": "github.com", + "owner": "adobe", + "path": "", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "directoryIndex": "index.html", + "package": "75f29aa936bfc2b84bde5ac0ee4afbf824b1391e-dirty", + "perf": { + "connection": "", + "device": "", + "location": "" + }, + "static": { + "allow": [], + "deny": [], + "host": "github.com", + "hostname": "github.com", + "magic": false, + "owner": "adobe", + "path": "/htdocs", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "sticky": false, + "urls": [] + }, + "default": { + "code": { + "host": "github.com", + "hostname": "github.com", + "owner": "adobe", + "path": "", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "condition": "", + "content": { + "host": "github.com", + "hostname": "github.com", + "owner": "adobe", + "path": "", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "directoryIndex": "index.html", + "package": "", + "perf": { + "connection": "", + "device": "", + "location": "" + }, + "static": { + "allow": [], + "deny": [], + "host": "github.com", + "hostname": "github.com", + "magic": false, + "owner": "adobe", + "path": "/htdocs", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "sticky": false, + "urls": [] + }, + "pipeline": { + "code": { + "host": "github.com", + "hostname": "github.com", + "owner": "adobe", + "path": "", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "condition": "req.http.host == \"pipeline.project-helix.io\"", + "content": { + "host": "github.com", + "hostname": "github.com", + "owner": "adobe", + "path": "", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "directoryIndex": "index.html", + "package": "", + "params": [ + "search", + "lang" + ], + "perf": { + "connection": "", + "device": "", + "location": "" + }, + "static": { + "allow": [], + "deny": [], + "host": "github.com", + "hostname": "github.com", + "magic": false, + "owner": "adobe", + "path": "/www", + "port": "", + "protocol": "https", + "ref": "master", + "repo": "project-helix.io" + }, + "sticky": true, + "urls": [] + }, + "proxy": { + "condition": "req.http.host == \"proxy.project-helix.io\"", + "origin": { + "address": "www.adobe.io", + "between_bytes_timeout": 10000, + "connect_timeout": 1000, + "error_threshold": 0, + "first_byte_timeout": 15000, + "hostname": "www.adobe.io", + "max_conn": 200, + "name": "Proxywwwadobeio861b", + "port": 443, + "shield": "iad-va-us", + "ssl_cert_hostname": "www.adobe.io", + "use_ssl": true, + "weight": 100 + }, + "params": [ + "search" + ], + "perf": { + "connection": "", + "device": "", + "location": "" + }, + "sticky": true, + "urls": [] + }, + "proxy-detailed": { + "condition": "", + "origin": { + "address": "192.168.0.1", + "between_bytes_timeout": 10000, + "connect_timeout": 1000, + "error_threshold": 0, + "first_byte_timeout": 0, + "hostname": "192.168.0.1", + "max_conn": 200, + "name": "Proxy1921680132fd", + "port": 80, + "shield": "iad-va-us", + "ssl_cert_hostname": "192.168.0.1", + "use_ssl": false, + "weight": 100 + }, + "perf": { + "connection": "", + "device": "", + "location": "" + }, + "sticky": false, + "urls": [] + } + }, + "version": 1 +} diff --git a/test/specs/configs/various_comments.yaml b/test/specs/configs/various_comments.yaml new file mode 100644 index 00000000..c004c506 --- /dev/null +++ b/test/specs/configs/various_comments.yaml @@ -0,0 +1,70 @@ +# Copyright 2018 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +version: 1 + +definitions: + constants: + defaultRepo: + &myrepo + owner: adobe + repo: project-helix.io + ref: master + strains: + base: + &basestrain + code: *myrepo + content: *myrepo + static: *myrepo + +strains: + default: *basestrain + + adhoc: + <<: *basestrain + package: 75f29aa936bfc2b84bde5ac0ee4afbf824b1391e-dirty + +# client: +# code: *myrepo +# static: *myrepo +# condition: req.http.host == "client.project-helix.io" +# sticky: false +# content: +# repo: helix-cli +# ref: master +# owner: adobe +# directoryIndex: readme.html + + pipeline: + <<: *basestrain + condition: req.http.host == "pipeline.project-helix.io" + params: + - search + - lang + #content: + # repo: hypermedia-pipeline + # ref: master + # owner: adobe + static: + <<: *myrepo + path: /www + + proxy: + origin: https://www.adobe.io/ + condition: req.http.host == "proxy.project-helix.io" + params: + - search + #- api* + sticky: true + + proxy-detailed: + origin: + address: 192.168.0.1 +# name: publish + use_ssl: false