text: /*** Generated by streamline 0.4.5 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch; var common = require("../common");
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  var fs = require("fs");
  var path = require("path");
  var url = require("url");
  var crypto = require("crypto");
  var pfx2pem = require("../../util/certificates/pkcs").pfx2pem;
  var Channel = require("../channel");
  var async = require("async");
  var child_process = require("child_process");
  var utils = require("../utils");
  var constants = require("../constants");
  var cacheUtils = require("../cacheUtils");
  
  exports.init = function(cli) {
  
    var log = cli.output;
    var site = cli.category("site");
    var scm = site.category("deployment");
    var repository = site.category("repository").description("Commands to manage your git repository");
  
  
    repository.command("branch <branch> [name]>").whiteListPowershell().usage("<branch> [name] [options]").description("set your repository branch").option("-s, --subscription <id>", "use the subscription id").execute(function __1(branch, name, options, _) { var context, repositoryUri; var __frame = { name: "__1", line: 42 }; return __func(_, this, arguments, __1, 3, __frame, function __$__1() {
  
  
  
  
  
        context = {
          subscription: cli.category("account").lookupSubscriptionId(options.subscription),
          settingKey: "branch",
          settingValue: branch,
          site: { name: name } };
  
  
        return scm.ensureRepositoryUri(context, __cb(_, __frame, 8, 26, function ___(__0, __1) { repositoryUri = __1; return (function __$__1(__then) {
            if (repositoryUri) {
              return doSettingsSet(context, __cb(_, __frame, 10, 8, __then, true)); } else {
  
              log.error("Repository is not setup"); __then(); } ; })(_); }, true)); }); });
  
  
  
    repository.command("delete [name]").whiteListPowershell().usage("[name] [options]").description("Delete your repository").option("-s, --subscription <id>", "use the subscription id").option("-q, --quiet", "quiet mode, do not ask for delete confirmation").execute(function __2(name, options, _) { var context, repositoryUri; var __frame = { name: "__2", line: 64 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() {
  
  
  
  
  
  
        context = {
          subscription: cli.category("account").lookupSubscriptionId(options.subscription),
          site: { name: name } };
  
  
        return scm.ensureRepositoryUri(context, __cb(_, __frame, 6, 26, function ___(__0, __2) { repositoryUri = __2; return (function __$__2(__then) {
            if (repositoryUri) { return (function __$__2(_) {
                var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return site.confirm("Delete repository?  (y/n) ", __cb(_, __frame, 8, 31, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -63, 17, function ___(__0, __3) { return (function __$__2(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$__2() {
  
  
  
                  return doDeleteRepository(context, __cb(_, __frame, 12, 8, function __$__2() {
                    return site.doRepositoryDelete(context, __cb(_, __frame, 13, 8, __then, true)); }, true)); }); }, true)); } else {
  
              log.error("Repository is not setup"); __then(); } ; })(_); }, true)); }); });
  
  
  
    function doSettingsGet(context, _) { var channel, progress; var __frame = { name: "doSettingsGet", line: 83 }; return __func(_, this, arguments, doSettingsGet, 1, __frame, function __$doSettingsGet() {
  
        channel = scm.getScmChannel(context).path("settings");
        if ((context.settingKey !== undefined)) {
          channel.path(context.settingKey); } ;
  
  
        progress = cli.progress((("Retrieving repository " + ((context.settingKey ? ((context.settingKey + " ")) : ""))) + "settings")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$doSettingsGet() {
  
              return channel.GET(__cb(_, __frame, 9, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$doSettingsGet() {
  
                progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
  
  
    repository.doSettingsGet = doSettingsGet;
  
    function doSettingsSet(context, _) { var channel, data, progress; var __frame = { name: "doSettingsSet", line: 99 }; return __func(_, this, arguments, doSettingsSet, 1, __frame, function __$doSettingsSet() {
  
        channel = scm.getScmChannel(context).path("settings");
        data = {
          key: context.settingKey,
          value: context.settingValue };
  
  
        progress = cli.progress(((("Setting " + context.settingKey) + " to ") + context.settingValue)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$doSettingsSet() {
  
              return channel.header("content-type", "application/json").POST(JSON.stringify(data), __cb(_, __frame, 10, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$doSettingsSet() {
  
                progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
  
  
  
    function doDeleteRepository(context, _) { var channel, progress; var __frame = { name: "doDeleteRepository", line: 115 }; return __func(_, this, arguments, doDeleteRepository, 1, __frame, function __$doDeleteRepository() {
  
        channel = scm.getScmChannel(context).path("live/scm");
  
        progress = cli.progress("Cleaning up repository files"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$doDeleteRepository() {
  
              return channel.DELETE(__cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$doDeleteRepository() {
  
                progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };};