@uniorg/localneo
Advanced tools
Comparing version 1.6.0 to 1.7.0
{ | ||
"name": "@uniorg/localneo", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"author": "m.schmale@uniorg.de", | ||
@@ -17,2 +17,5 @@ "license": "MIT", | ||
"homepage": "https://github.com/UNIORG-Solutions/localneo", | ||
"publishConfig": { | ||
"@uniorg:registry": "https://registry.npmjs.org/" | ||
}, | ||
"bin": { | ||
@@ -19,0 +22,0 @@ "localneo": "./start.js" |
@@ -35,3 +35,3 @@ const fs = require('fs') | ||
return new TargetInfo({ path, desc, target, name }) | ||
return new TargetInfo({path, desc, target, name}) | ||
}) | ||
@@ -60,3 +60,3 @@ | ||
case 'application': | ||
if (!this.dest.applications || !this.dest.applications[ targetInfo.name ]) { | ||
if (!this.dest.applications || !this.dest.applications[targetInfo.name]) { | ||
console.error(`${this.name}: cannot find application definition for target ${targetInfo.name}`) | ||
@@ -70,3 +70,6 @@ if (reg.has('app:' + targetInfo.name)) { | ||
let app = this.getAppTarget(this.dest.applications[ targetInfo.name ]) | ||
let app = this.getAppTarget(Object.assign({ | ||
name: targetInfo.name, | ||
localUrl: targetPath | ||
}, this.dest.applications[targetInfo.name])) | ||
@@ -78,3 +81,3 @@ if (app) { | ||
case 'destination': | ||
if (!this.dest.destinations || !this.dest.destinations[ targetInfo.name ]) { | ||
if (!this.dest.destinations || !this.dest.destinations[targetInfo.name]) { | ||
console.error(`${this.name}: cannot find destination definition for target ${targetInfo.name}`) | ||
@@ -88,3 +91,3 @@ if (reg.has('dest:' + targetInfo.name)) { | ||
let dest = this.getDestTarget(this.dest.destinations[ targetInfo.name ], targetInfo, targetPath) | ||
let dest = this.getDestTarget(this.dest.destinations[targetInfo.name], targetInfo, targetPath) | ||
if (dest) { | ||
@@ -97,10 +100,15 @@ reg.put('dest:' + targetInfo.name, dest) | ||
let serviceConfig = {} | ||
if (this.dest && this.dest.service && this.dest.service[ targetInfo.name ]) { | ||
serviceConfig = this.dest.service[ targetInfo.name ] | ||
if (this.dest && this.dest.service && this.dest.service[targetInfo.name]) { | ||
serviceConfig = this.dest.service[targetInfo.name] | ||
} | ||
return ServiceFactory.create(targetInfo, targetPath, serviceConfig) | ||
if (!reg.has(`srv:${targetInfo.name}@${targetInfo.entryPath}`)) { | ||
reg.put(`srv:${targetInfo.name}@${targetInfo.entryPath}`, ServiceFactory.create(targetInfo, targetPath, serviceConfig)) | ||
} | ||
return reg.get(`srv:${targetInfo.name}@${targetInfo.entryPath}`) | ||
} | ||
} | ||
getDestTarget ({ url: proxyUrl, auth }, { entryPath }, incomingPath) { | ||
getDestTarget ({url: proxyUrl, auth}, {entryPath}, incomingPath) { | ||
return new Destination({ | ||
@@ -114,3 +122,14 @@ url: proxyUrl, | ||
getAppTarget ({ path: appPath, name }) { | ||
directoryExists (path) { | ||
try { | ||
return !fs.statSync(path).isDirectory() | ||
} catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
console.error(err) | ||
} | ||
return false | ||
} | ||
} | ||
getAppTarget ({path: appPath, name, remotePath, preferLocal, localUrl}) { | ||
if (!path.isAbsolute(appPath)) { | ||
@@ -120,14 +139,18 @@ appPath = path.normalize(path.join(this.dir, appPath)) | ||
try { | ||
if (!fs.statSync(appPath).isDirectory()) { | ||
console.error(`cannot find direcory "${appPath}" for target ${name}`) | ||
} | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { | ||
console.error(`cannot find direcory "${appPath}" for target ${name}`) | ||
} else { | ||
console.error(err) | ||
} | ||
const dirExists = this.directoryExists(appPath) | ||
if (!dirExists && remotePath === undefined) { | ||
console.error(`cannot find direcory "${appPath}" for target ${name}`) | ||
return | ||
} | ||
if (remotePath && (preferLocal === false || !dirExists)) { | ||
// proxy remote | ||
console.warn(`redirecting to remote destination ${remotePath}`) | ||
return new Destination({ | ||
url: remotePath, | ||
localPath: localUrl | ||
}) | ||
} | ||
let appReader = MapReader.fromApplicationDirectory(appPath) | ||
@@ -134,0 +157,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50555
454