From 98bd95bbd86ca1abcc9b5c39ea75984828e71044 Mon Sep 17 00:00:00 2001 From: German Galvis Date: Fri, 14 Dec 2018 13:33:30 -0500 Subject: [PATCH 1/8] post processor to JSON stringified to allow valid SG field values --- lib/utils/inserter.js | 50 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/utils/inserter.js b/lib/utils/inserter.js index 5cb1771..9ac3c29 100644 --- a/lib/utils/inserter.js +++ b/lib/utils/inserter.js @@ -8,31 +8,37 @@ const utils = require('./utils') function getConstant(value, constants) { - const keys = value.split('.') - let obj = constants - keys.forEach(key => { - if (obj && obj[key]) { - obj = obj[key] - } else { - obj = null - } - }) - if (obj) { - if(typeof obj == 'string') { - return obj - } else { - try { - return JSON.stringify(obj) - } catch (error) { - log.error(`Failed to find ${value}`) - return - } - } + const keys = value.split('.') + let obj = constants + + keys.forEach(key => { + if (obj && obj[key]) { + obj = obj[key] + } else { + obj = null + } + }) + if (obj) { + if(typeof obj == 'string') { + return obj } else { - log.error(`Failed to find ${value}`) - return + try { + return getSGCompatibleJsonStr(JSON.stringify(obj)) + } catch (error) { + log.error(`Failed to find ${value}`) + return + } } + } else { + log.error(`Failed to find ${value}`) + return } +} + +function getSGCompatibleJsonStr(jsonStr) { + const keyValRegex = /([{,])"(\w+)"(\:[{["0-9])/gi + return jsonStr.replace(keyValRegex, '$1$2$3') +} function insertConstants(src, constants, filename) { const regex = /@{(.*?)}/g From 46fbe77680e59c69d03190c303929df60bff379b Mon Sep 17 00:00:00 2001 From: German Galvis Date: Fri, 14 Dec 2018 13:35:20 -0500 Subject: [PATCH 2/8] removing what looks like a useless mkdirp which breaks CI flows --- lib/commands/make.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/make.js b/lib/commands/make.js index 64599a6..a4a778e 100644 --- a/lib/commands/make.js +++ b/lib/commands/make.js @@ -11,7 +11,7 @@ const childProcess = require('child_process') const temp = '.ukor' function moveToTempDir(flavor) { - mkdirp(temp) + //mkdirp(temp) <- seems like extra step that gives us problems later if (fs.existsSync(flavor)) { fse.copySync(flavor, temp, { filter: name => { From 1ee69d9012f708b9280be7029a243fba0014844e Mon Sep 17 00:00:00 2001 From: German Galvis Date: Fri, 14 Dec 2018 13:35:55 -0500 Subject: [PATCH 3/8] passing ip as a property - fallback for dockerized envs --- lib/commands/test.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/commands/test.js b/lib/commands/test.js index 9a4a41e..233dcdc 100644 --- a/lib/commands/test.js +++ b/lib/commands/test.js @@ -65,8 +65,8 @@ function runLogServer(ip, port, timeout, callback) { }) }) }) - logServer.listen(parseInt(port), getIP.address(), () => { - log.info('listening for tests on %s:%s', getIP.address(), port) + logServer.listen(parseInt(port), getLocalIp(), () => { + log.info('listening for tests on %s:%s', getLocalIp(), port) }) return logServer } @@ -117,13 +117,17 @@ function writeJunit(stats) { log.info('successfully wrote junit xml') } +function getLocalIp() { + return properties.localIp || getIP.address() +} + function runTests(ip, auth, port, callback) { setTimeout(() => { let url = 'http://' + ip + ':8060/launch/dev?RunTests=true&host=' + - getIP.address() + + getLocalIp() + '&port=' + port log.debug('starting tests with: %s', url) From 1ccaa6c4fd79cb5c4e73cfd3d99ba71075d43625 Mon Sep 17 00:00:00 2001 From: German Galvis Date: Fri, 14 Dec 2018 13:36:49 -0500 Subject: [PATCH 4/8] version bump --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2a07d78..2f63f55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@willowtreeapps/ukor", - "version": "1.1.3", + "version": "1.1.4", "description": "Roku build tool with flavors and deployment", "keywords": [ "roku", @@ -44,7 +44,6 @@ "@willowtreeapps/wist": "^2.0.1", "ajv": "^6.5.4", "ajv-keywords": "^3.2.0", - "xml2js": "^0.4.19", "archiver": "^3.0.0", "commander": "^2.18.0", "fs-extra": "^7.0.0", @@ -57,7 +56,8 @@ "request": "^2.88.0", "rimraf": "^2.6.2", "winston": "^3.1.0", - "xml-writer": "^1.7.0" + "xml-writer": "^1.7.0", + "xml2js": "^0.4.19" }, "devDependencies": { "eslint": "^4.19.1", From 9563e939bd270709d72168f06a9ebd7d3e8b27c1 Mon Sep 17 00:00:00 2001 From: German Galvis Date: Fri, 14 Dec 2018 13:40:28 -0500 Subject: [PATCH 5/8] package update --- package.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f63f55..f6d63ea 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/willowtreeapps/ukor" + "url": "git+https://github.com/willowtreeapps/ukor.git" }, "author": "WillowTree Inc.", "publisher": "willowtreeapps", @@ -66,5 +66,12 @@ "eslint-plugin-node": "^5.0.0", "eslint-plugin-promise": "^3.8.0", "eslint-plugin-standard": "^3.1.0" + }, + "bugs": { + "url": "https://github.com/willowtreeapps/ukor/issues" + }, + "homepage": "https://github.com/willowtreeapps/ukor#readme", + "directories": { + "lib": "lib" } } From 2c2d5b70ce3ffe5bf2e223850f43dc6336e80b09 Mon Sep 17 00:00:00 2001 From: German Galvis Date: Fri, 14 Dec 2018 13:43:43 -0500 Subject: [PATCH 6/8] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f6d63ea..7cef958 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@willowtreeapps/ukor", - "version": "1.1.4", + "version": "1.1.7", "description": "Roku build tool with flavors and deployment", "keywords": [ "roku", From 8e36d528af61de1527a650e5bab4b28f979df2f6 Mon Sep 17 00:00:00 2001 From: German Galvis Date: Fri, 14 Dec 2018 16:47:35 -0500 Subject: [PATCH 7/8] adding safe string for double quotes to add flexibility / version bump --- lib/utils/inserter.js | 7 +++++-- package.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/utils/inserter.js b/lib/utils/inserter.js index 9ac3c29..d155f54 100644 --- a/lib/utils/inserter.js +++ b/lib/utils/inserter.js @@ -36,8 +36,11 @@ function getConstant(value, constants) { } function getSGCompatibleJsonStr(jsonStr) { - const keyValRegex = /([{,])"(\w+)"(\:[{["0-9])/gi - return jsonStr.replace(keyValRegex, '$1$2$3') + const keyValRegex = /([{,])"(\w+)"(\:)/gi + // cleaning faulty double quotes from key names + let safeStr = jsonStr.replace(keyValRegex, '$1$2$3') + //... and replacing the rest for a safe string + return safeStr.replace(/"/g, '"') } function insertConstants(src, constants, filename) { diff --git a/package.json b/package.json index 7cef958..550d173 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@willowtreeapps/ukor", - "version": "1.1.7", + "version": "1.1.8", "description": "Roku build tool with flavors and deployment", "keywords": [ "roku", From 051541c447b0826aa02a32f628a7f38e26b8d03e Mon Sep 17 00:00:00 2001 From: German Galvis Date: Mon, 17 Dec 2018 16:53:48 -0500 Subject: [PATCH 8/8] bum version - avoiding falsey values triggering errors --- lib/utils/inserter.js | 7 ++++--- package.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/utils/inserter.js b/lib/utils/inserter.js index d155f54..e87a8d7 100644 --- a/lib/utils/inserter.js +++ b/lib/utils/inserter.js @@ -12,13 +12,14 @@ function getConstant(value, constants) { let obj = constants keys.forEach(key => { - if (obj && obj[key]) { + if ((obj || {})[key] !== null) { obj = obj[key] } else { obj = null } }) - if (obj) { + + if (obj !== null) { if(typeof obj == 'string') { return obj } else { @@ -53,7 +54,7 @@ function insertConstants(src, constants, filename) { let count = 0 src = src.replace(regex, (match, p, offset, str) => { let replace = getConstant(p, constants) - if (replace) { + if (replace !== null) { if (log.level === 'debug') { const lines = src.substring(0, offset).split(os.EOL) const last = lines[lines.length - 1] diff --git a/package.json b/package.json index 550d173..2cedce3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@willowtreeapps/ukor", - "version": "1.1.8", + "version": "1.1.9", "description": "Roku build tool with flavors and deployment", "keywords": [ "roku",