pandora
Version:
130 lines • 5.28 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const AppletRepresentationChainModifier_1 = require("./AppletRepresentationChainModifier");
const ServiceRepresentationChainModifier_1 = require("./ServiceRepresentationChainModifier");
const ProcessRepresentationChainModifier_1 = require("./ProcessRepresentationChainModifier");
const pandora_dollar_1 = require("pandora-dollar");
/**
* Class ProcfileReconcilerAccessor
* A easy way to access ProcfileReconciler
*/
class ProcfileReconcilerAccessor {
constructor(procfileReconciler) {
this.procfileReconciler = null;
this.procfileReconciler = procfileReconciler;
}
get appName() {
return this.procfileReconciler.appRepresentation.appName;
}
get appDir() {
return this.procfileReconciler.appRepresentation.appDir;
}
defaultAppletCategory(name) {
this.procfileReconciler.setDefaultAppletCategory(name);
}
defaultServiceCategory(name) {
this.procfileReconciler.setDefaultServiceCategory(name);
}
/**
* Inject environment class
* @param {Entry} entry
*/
environment(entry) {
this.procfileReconciler.injectEnvironment(entry);
}
/**
* inject configurator class
* @param {Entry} entry
*/
configurator(entry) {
this.procfileReconciler.injectConfigurator(entry);
}
/**
* define process
* @param processName
* @return {ProcessRepresentationChainModifier}
*/
process(processName) {
const savedRepresentation = this.procfileReconciler.getProcessByName(processName);
if (this.procfileReconciler.getProcessByName(processName)) {
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(savedRepresentation);
}
const representation = this.procfileReconciler.defineProcess({ processName });
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(representation);
}
/**
* Define fork a process
* @param entryFile
* @param processName
* @return {ProcessRepresentationChainModifier}
*/
fork(entryFile, processName) {
const savedRepresentation = this.procfileReconciler.getProcessByName(processName);
if (savedRepresentation) {
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(savedRepresentation);
}
const representation = this.procfileReconciler.defineProcess({
entryFile,
processName,
mode: 'fork'
});
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(representation);
}
/**
* Inject applet class
* @param appletEntry
* @return {AppletRepresentationChainModifier}
*/
applet(appletEntry) {
const savedRepresentation = this.procfileReconciler.getAppletByEntry(appletEntry);
if (savedRepresentation) {
return new AppletRepresentationChainModifier_1.AppletRepresentationChainModifier(savedRepresentation);
}
const representation = this.procfileReconciler.injectApplet({ appletEntry });
return new AppletRepresentationChainModifier_1.AppletRepresentationChainModifier(representation);
}
/**
* Inject service class
* @param serviceEntry
* @return {ServiceRepresentationChainModifier}
*/
service(serviceEntry) {
const savedRepresentation = this.procfileReconciler.getServiceByEntry(serviceEntry);
if (savedRepresentation) {
return new ServiceRepresentationChainModifier_1.ServiceRepresentationChainModifier(savedRepresentation);
}
const representation = this.procfileReconciler.injectService({ serviceEntry });
return new ServiceRepresentationChainModifier_1.ServiceRepresentationChainModifier(representation);
}
/**
* An alias to applet()
* @param path
* @return {AppletRepresentationChainModifier}
*/
cluster(path) {
const baseDir = this.procfileReconciler.procfileBasePath;
class ClusterApplet {
start() {
return __awaiter(this, void 0, void 0, function* () {
if (baseDir) {
pandora_dollar_1.makeRequire(baseDir)(path);
}
else {
require(path);
}
});
}
}
return this.applet(ClusterApplet);
}
}
exports.ProcfileReconcilerAccessor = ProcfileReconcilerAccessor;
//# sourceMappingURL=ProcfileReconcilerAccessor.js.map