"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const ReplaySubject_1 = require("rxjs/ReplaySubject");
const jar_1 = require("./jar");
function deploy(project, options) {
    const subject = new ReplaySubject_1.ReplaySubject();
    const packageOptions = require(path.resolve(project.root, 'package.json'));
    const Gogo = require('./gogo-deploy').GogoDeployer;
    let outputPath = path.resolve(project.root, options.outputJarPath);
    let jarPath = path.resolve(outputPath, packageOptions.name + '.jar');
    jar_1.jar(project, options).subscribe(() => {
        let gogo = new Gogo({ connectConfig: { host: options.host, port: options.port } });
        gogo.on('error', (error) => {
            subject.error(error);
            subject.complete();
        });
        gogo.deploy(jarPath, packageOptions.name).then((data) => {
            gogo.destroy();
            subject.next(data);
            subject.complete();
        });
    }, error => {
        subject.error(error);
        subject.complete();
    });
    return subject.asObservable();
}
exports.deploy = deploy;
//# sourceMappingURL=/home/ddavis/Projects/xtivia/speedray/speedray-cli/lib/speedray/deploy.js.map