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 => { 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) diff --git a/lib/utils/inserter.js b/lib/utils/inserter.js index 5cb1771..e87a8d7 100644 --- a/lib/utils/inserter.js +++ b/lib/utils/inserter.js @@ -8,31 +8,41 @@ 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 || {})[key] !== null) { + obj = obj[key] } else { - log.error(`Failed to find ${value}`) - return + obj = null } + }) + + if (obj !== null) { + if(typeof obj == 'string') { + return obj + } else { + 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+)"(\:)/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) { const regex = /@{(.*?)}/g @@ -44,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 2a07d78..2cedce3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@willowtreeapps/ukor", - "version": "1.1.3", + "version": "1.1.9", "description": "Roku build tool with flavors and deployment", "keywords": [ "roku", @@ -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", @@ -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", @@ -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" } }