Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes and some features #61

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
10 changes: 7 additions & 3 deletions lib/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down
56 changes: 33 additions & 23 deletions lib/utils/inserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '&quot;')
}

function insertConstants(src, constants, filename) {
const regex = /@{(.*?)}/g
Expand All @@ -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]
Expand Down
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
}