Merge remote-tracking branch 'upstream/management' into management

Conflicts:
	lib/cli/commands/site.js
	lib/cli/commands/site_.js
This commit is contained in:
Andre Rodrigues 2012-05-22 23:17:45 -07:00
Родитель 65c74d9cc8 9e4d4d32f1
Коммит e740e0fd21
9 изменённых файлов: 1680 добавлений и 462 удалений

Просмотреть файл

@ -27,6 +27,10 @@ function getSitesFile(context) {
return path.join(utils.azureDir(), "sites." + context.subscription + ".json");
}
function getCommitIdsFile(context) {
return path.join(utils.azureDir(), "commitids." + context.subscription + ".json");
}
function readSpaces(context, cb) {
var cacheFile = getSpacesFile(context);
return path.exists(cacheFile, function (exists) {
@ -117,12 +121,47 @@ function saveSites(context, sites, cb) {
});
}
function saveCommitIds(context, deployments, cb) {
var cacheFile = getCommitIdsFile(context);
var commitIds = deployments.map(function (deployment) {
return {
shortId: deployment.shortId,
id: deployment.id
};
});
return fs.writeFile(cacheFile, JSON.stringify(commitIds), function (err) {
cb && cb(err, deployments);
});
}
function readCommitId(context, cb) {
var cacheFile = getCommitIdsFile(context);
return path.exists(cacheFile, function (exists) {
if (exists) {
return fs.readFile(cacheFile, function (err, data) {
var commitIds = JSON.parse(data);
if (commitIds && commitIds.length) {
for (var i = 0; i < commitIds.length; i++) {
if (utils.ignoreCaseEquals(context.shortId, commitIds[i].shortId)) {
return cb && cb(null, commitIds[i].id);
}
}
}
return cb && cb(null, null);
});
}
return cb && cb(null, null);
});
}
function clear() {
var isDeleted = false;
if (path.existsSync(utils.azureDir())) {
var cacheFiles = fs.readdirSync(utils.azureDir());
for (var i = 0; i < cacheFiles.length; ++i) {
if (/sites[.].+[.]json/.test(cacheFiles[i]) || /spaces[.].+[.]json/.test(cacheFiles[i])) {
if (/sites[.].+[.]json/.test(cacheFiles[i])
|| /spaces[.].+[.]json/.test(cacheFiles[i])
|| /deployments[.].+[.]json/.test(cacheFiles[i])) {
fs.unlinkSync(path.join(utils.azureDir(), cacheFiles[i]));
isDeleted = true;
}
@ -137,6 +176,8 @@ CacheUtils.readSite = readSite;
CacheUtils.saveSite = saveSite;
CacheUtils.deleteSite = deleteSite;
CacheUtils.saveSites = saveSites;
CacheUtils.saveCommitIds = saveCommitIds;
CacheUtils.readCommitId = readCommitId;
CacheUtils.clear = clear;
module.exports = CacheUtils;

Просмотреть файл

@ -88,26 +88,43 @@ Channel.prototype.send = function (method, data, cb) {
log.silly('Request.Method', options.method);
log.silly('Request.Path', options.path);
var req = https.request(options, function (res) {
var done = 0;
var parser = new xml2js.Parser();
var data = [],
dataLen = 0,
contentType;
log.silly('Response.Headers', res.headers);
res.on('data', function (data) {
log.silly('Response.Data', data.toString());
try {
parser.parseString(data);
}
catch (err) {
cb(err);
}
res.on('data', function (chunk) {
data.push(chunk);
dataLen += chunk.length;
contentType = contentType || res.headers['content-type'];
});
res.on('end', function () {
if (++done == 1) cb(null, {});
});
parser.on('end', function (result) {
if (result.Message && result.Code) {
if (++done == 1) cb(result, null);
if (!dataLen) {
return cb && cb(null, null);
}
var buf = new Buffer(dataLen);
for (var i = 0, len = data.length, pos = 0; i < len; i++) {
data[i].copy(buf, pos);
pos += data[i].length;
}
if (contentType && contentType.indexOf('application/json') != -1) {
return cb && cb(null, JSON.parse(buf.toString()));
} else if (contentType && contentType.indexOf('application/zip') != -1) {
return cb && cb(null, buf);
} else {
if (++done == 1) cb(null, result);
var parser = new xml2js.Parser();
parser.on('end', function (result) {
if (result.Message && result.Code) {
return cb && cb(result, null);
} else {
return cb && cb(null, result);
}
});
try {
parser.parseString(buf);
}
catch (err) {
return cb && cb(err);
}
}
});
});

Просмотреть файл

@ -0,0 +1,562 @@
/*** Generated by streamline 0.2.5 - DO NOT EDIT ***/
var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch,__propagate=__rt.__propagate,__trap=__rt.__trap,__future=__rt.__future,__setEF=__rt.__setEF,__g=__rt.__g;
/* 1 */ var common = require("../common");
/* 20 */ var fs = require("fs");
/* 21 */ var path = require("path");
/* 22 */ var url = require("url");
/* 23 */ var crypto = require("crypto");
/* 24 */ var pfx2pem = require("../../util/certificates/pkcs").pfx2pem;
/* 25 */ var Channel = require("../channel");
/* 26 */ var async = require("async");
/* 27 */ var child_process = require("child_process");
/* 28 */ var utils = require("../utils");
/* 29 */ var constants = require("../constants");
/* 30 */ var cacheUtils = require("../cacheUtils");
/* 32 */ exports.init = function(cli) {
/* 34 */ var log = cli.output;
/* 35 */ var site = cli.category("site");
/* 36 */ var scm = site.category("deployment").description("Commands to manage your git deployments");
/* 39 */ function getScmChannel(context) {
/* 40 */ var parts = url.parse(context.repositoryUri);
/* 41 */ var channel = new Channel({
/* 42 */ host: parts.hostname,
/* 43 */ port: (((parts.port && parseInt(parts.port, 10))) || ((/https/i.test(parts.protocol) ? 443 : 80))),
/* 44 */ auth: context.repositoryAuth
});
/* 47 */ var proxyString = (((process.env.HTTPS_PROXY || process.env.https_proxy) || process.env.ALL_PROXY) || process.env.all_proxy);
/* 53 */ if ((proxyString !== undefined)) {
/* 54 */ var proxyUrl = url.parse(proxyString);
/* 55 */ if (((proxyUrl.protocol !== "http:") && (proxyUrl.protocol !== "https:"))) {
/* 58 */ proxyUrl = url.parse(("http://" + proxyString));
}
;
/* 61 */ channel = channel.add({
/* 61 */ proxy: proxyUrl
});
}
;
/* 64 */ return channel;
};
/* 66 */ scm.getScmChannel = getScmChannel;
/* 68 */ scm.command("list [name]").whiteListPowershell().usage("[options] [name]").description("List your git deployments").option("-s, --subscription <id>", "use the subscription id").option("-m, --max <count>", "limit the maximum number of results").execute(function __1(name, options, _) {
var context, repositoryUri;
var __frame = {
name: "__1",
line: 74
};
return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
/* 75 */ context = {
/* 76 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 77 */ maxItems: options.max,
/* 78 */ site: {
/* 79 */ name: name
}
};
/* 83 */ return ensureRepositoryUri(context, __cb(_, __frame, 9, 26, function ___(__0, __1) {
repositoryUri = __1;
return (function __$__1(__then) {
/* 84 */ if (repositoryUri) {
/* 85 */ return listDeployments(context, __cb(_, __frame, 11, 8, __then, true));
}
else {
/* 87 */ log.error("Repository is not setup");
__then();
}
;
})(_);
}, true));
});
});
/* 91 */ scm.command("show <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Show your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) {
var context, repositoryUri, deployment;
var __frame = {
name: "__2",
line: 97
};
return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
/* 98 */ context = {
/* 99 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 100 */ shortId: commitId,
/* 101 */ site: {
/* 102 */ name: name
}
};
/* 106 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) {
/* 106 */ var __1 = !(context.id = __2);
return (function __$__2(__then) {
if (__1) {
/* 107 */ return _(null, log.error((("deployment with " + commitId) + " does not exist")));
}
else {
__then();
}
;
})(function __$__2() {
/* 110 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) {
repositoryUri = __3;
return (function __$__2(__then) {
/* 111 */ if (repositoryUri) {
/* 112 */ return scm.doDeploymentGet(context, __cb(_, __frame, 15, 25, function ___(__0, __4) {
deployment = __4;
/* 113 */ site.logEachData("info", deployment);
return (function __$__2(__then) {
/* 114 */ if (options.details) {
/* 115 */ return showLogDetails(context, __cb(_, __frame, 18, 10, __then, true));
}
else {
/* 117 */ log.help("To see more details, specify -d or --details option");
__then();
}
;
})(__then);
}, true));
}
else {
/* 120 */ log.error("Repository is not setup");
__then();
}
;
})(_);
}, true));
});
}, true));
});
});
/* 124 */ scm.command("redeploy <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Redeploy your git deployment").option("-s, --subscription <id>", "use the subscription id").execute(function __3(commitId, name, options, _) {
var context, repositoryUri;
var __frame = {
name: "__3",
line: 129
};
return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
/* 130 */ context = {
/* 131 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 132 */ shortId: commitId,
/* 133 */ site: {
/* 134 */ name: name
}
};
/* 138 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) {
/* 138 */ var __1 = !(context.id = __2);
return (function __$__3(__then) {
if (__1) {
/* 139 */ return _(null, log.error((("deployment with " + commitId) + " does not exist")));
}
else {
__then();
}
;
})(function __$__3() {
/* 142 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) {
repositoryUri = __3;
return (function __$__3(__then) {
/* 143 */ if (repositoryUri) {
/* 144 */ return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 13, function ___(__0, __5) {
/* 144 */ var __4 = !__5;
return (function __$__3(__then) {
if (__4) {
return _(null);
}
else {
__then();
}
;
})(function __$__3() {
/* 147 */ return scm.doDeploymentPut(context, __cb(_, __frame, 18, 8, function __$__3() {
/* 148 */ return listDeployments(context, __cb(_, __frame, 19, 8, __then, true));
}, true));
});
}, true));
}
else {
/* 150 */ log.error("Repository is not setup");
__then();
}
;
})(_);
}, true));
});
}, true));
});
});
/* 154 */ scm.doDeploymentsGet = function scm_doDeploymentsGet__4(context, _) {
var maxItems, channel, progress, deployments;
var __frame = {
name: "scm_doDeploymentsGet__4",
line: 154
};
return __func(_, this, arguments, scm_doDeploymentsGet__4, 1, __frame, function __$scm_doDeploymentsGet__4() {
/* 155 */ maxItems = parseInt(context.maxItems, 10);
/* 156 */ if ((!maxItems || (maxItems <= 0))) {
/* 157 */ maxItems = 20;
}
;
/* 163 */ channel = getScmChannel(context).path("deployments").query("$orderby", "ReceivedTime desc").query("$top", maxItems);
/* 165 */ progress = cli.progress("Enumerating deployments");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$scm_doDeploymentsGet__4() {
/* 167 */ return channel.GET(__cb(_, __frame, 13, 44, function ___(__0, __1) {
/* 167 */ deployments = ensureShortCommitId(__1);
/* 168 */ return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__4() {
/* 169 */ return _(null, deployments.map(formatDeployment));
}, true));
}, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$scm_doDeploymentsGet__4() {
/* 171 */ progress.end();
__then();
});
})(function ___() {
__tryCatch(_, function ___() {
if (__cont) {
__then();
} else {
_(__e, __r);
};
});
});
});
})(function ___() {
__tryCatch(_, _);
});
});
};
/* 175 */ scm.doDeploymentGet = function scm_doDeploymentGet__5(context, _) {
var channel, progress;
var __frame = {
name: "scm_doDeploymentGet__5",
line: 175
};
return __func(_, this, arguments, scm_doDeploymentGet__5, 1, __frame, function __$scm_doDeploymentGet__5() {
/* 178 */ channel = getScmChannel(context).path("deployments").path(context.id);
/* 179 */ progress = cli.progress("Retrieving deployment info");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$scm_doDeploymentGet__5() {
/* 181 */ return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) {
/* 181 */ var __1 = formatDeployment(__2);
return _(null, __1);
}, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$scm_doDeploymentGet__5() {
/* 183 */ progress.end();
__then();
});
})(function ___() {
__tryCatch(_, function ___() {
if (__cont) {
__then();
} else {
_(__e, __r);
};
});
});
});
})(function ___() {
__tryCatch(_, _);
});
});
};
/* 187 */ scm.doDeploymentPut = function scm_doDeploymentPut__6(context, _) {
var channel, progress;
var __frame = {
name: "scm_doDeploymentPut__6",
line: 187
};
return __func(_, this, arguments, scm_doDeploymentPut__6, 1, __frame, function __$scm_doDeploymentPut__6() {
/* 190 */ channel = getScmChannel(context).path("deployments").path(context.id);
/* 191 */ progress = cli.progress("Redeploying deployment");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$scm_doDeploymentPut__6() {
/* 193 */ return channel.PUT(null, __cb(_, __frame, 6, 13, _, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$scm_doDeploymentPut__6() {
/* 195 */ progress.end();
__then();
});
})(function ___() {
__tryCatch(_, function ___() {
if (__cont) {
__then();
} else {
_(__e, __r);
};
});
});
});
})(function ___() {
__tryCatch(_, _);
});
});
};
/* 199 */ scm.doLogGet = function scm_doLogGet__7(context, _) {
var channel, progress, logs;
var __frame = {
name: "scm_doLogGet__7",
line: 199
};
return __func(_, this, arguments, scm_doLogGet__7, 1, __frame, function __$scm_doLogGet__7() {
/* 203 */ channel = getScmChannel(context).path("deployments").path(context.id).path("log");
/* 204 */ progress = cli.progress("Retrieving deployment log info");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$scm_doLogGet__7() {
/* 206 */ return channel.GET(__cb(_, __frame, 7, 17, function ___(__0, __1) {
logs = __1;
/* 207 */ return _(null, logs.map(formatLog));
}, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$scm_doLogGet__7() {
/* 209 */ progress.end();
__then();
});
})(function ___() {
__tryCatch(_, function ___() {
if (__cont) {
__then();
} else {
_(__e, __r);
};
});
});
});
})(function ___() {
__tryCatch(_, _);
});
});
};
/* 213 */ function listDeployments(context, _) {
var deployments, authorLength, messageLength;
var __frame = {
name: "listDeployments",
line: 213
};
return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() {
/* 214 */ return scm.doDeploymentsGet(context, __cb(_, __frame, 1, 22, function ___(__0, __1) {
deployments = __1;
/* 215 */ authorLength = 0;
/* 215 */ messageLength = 0;
/* 216 */ log.table(deployments, function(row, deployment) {
/* 217 */ row.cell("Time", deployment.start_time);
/* 218 */ row.cell("Commit id", deployment.shortId);
/* 219 */ row.cell("Status", deployment.status);
/* 220 */ authorLength = Math.max(deployment.author.length, authorLength);
/* 221 */ row.cell("Author", deployment.author, null, Math.min(authorLength, 15));
/* 222 */ messageLength = Math.max(deployment.message.length, messageLength);
/* 223 */ row.cell("Message", deployment.message, null, Math.min(messageLength, 40));
});
_();
}, true));
});
};
/* 227 */ function showLogDetails(context, _) {
var results, logs, progress, i, details, j;
var __frame = {
name: "showLogDetails",
line: 227
};
return __func(_, this, arguments, showLogDetails, 1, __frame, function __$showLogDetails() {
/* 229 */ return scm.doLogGet(context, __cb(_, __frame, 2, 15, function ___(__0, __2) {
logs = __2;
return (function __$showLogDetails(__then) {
/* 230 */ if ((logs && logs.length)) {
/* 231 */ progress = cli.progress("Retrieving log details");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$showLogDetails() {
/* 233 */ return async.map(logs, function __1(log, _) {
var details;
var __frame = {
name: "__1",
line: 233
};
return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
return (function __$__1(__then) {
/* 234 */ if (log.hasDetails) {
/* 240 */ return getScmChannel(context).path("deployments").path(context.id).path("log").path(log.id).GET(__cb(_, __frame, 7, 26, function ___(__0, __1) {
details = __1;
/* 241 */ return _(null, details.map(formatLog));
}, true));
}
else {
__then();
}
;
})(_);
});
}, __cb(_, __frame, 6, 18, function ___(__0, __3) {
/* 233 */ results = __3;
_(null, null, true);
}, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$showLogDetails() {
/* 245 */ progress.end();
__then();
});
})(function ___() {
__tryCatch(_, function ___() {
if (__cont) {
__then();
} else {
_(__e, __r);
};
});
});
});
})(function ___() {
__tryCatch(_, function __$showLogDetails() {
/* 247 */ for (i = 0; (i < logs.length); ++i) {
/* 248 */ displayLog(logs[i]);
/* 249 */ if (results[i]) {
/* 250 */ details = results[i];
/* 251 */ for (j = 0; (j < details.length); ++j) {
/* 252 */ displayLog(details[j]);
};
}
;
};
__then();
});
});
}
else {
/* 257 */ log.info("deployment has no detail");
__then();
}
;
})(_);
}, true));
});
};
/* 261 */ function displayLog(item) {
/* 262 */ if ((item.type === "Warning")) {
/* 263 */ log.warn(((item.short_time + " ") + item.message));
}
/* 264 */ else if ((item.type === "Error")) {
/* 265 */ log.error(((item.short_time + " ") + item.message));
}
/* 266 */ else {
/* 267 */ log.data(((item.short_time + " ") + item.message));
}
;
};
/* 271 */ function fromJsonDate(str) {
/* 272 */ return eval(str.replace(/\/Date\((.*)[+].*\)\//gi, "new Date($1)"));
};
/* 275 */ function formatDate(dt) {
/* 276 */ var date = dt.getDate(), month = dt.getMonth();
/* 278 */ date = ((((date < 10) ? "0" : "")) + date);
/* 279 */ month = ((((month < 10) ? "0" : "")) + month);
/* 280 */ return ((((((dt.getFullYear() + "-") + month) + "-") + date) + " ") + dt.toLocaleTimeString());
};
/* 283 */ function dateTimeText(str) {
/* 284 */ return formatDate(fromJsonDate(str));
};
/* 287 */ function deploymentStatusText(status) {
/* 288 */ switch (status) {
/* 289 */ case 0:
/* 289 */ return "Pending";
/* 289 */ case 1:
return "Building";
/* 290 */ case 2:
/* 290 */ return "Deploying";
/* 290 */ case 3:
return "Failed";
/* 291 */ case 4:
/* 291 */ return "Success";
/* 291 */ default:
return "Unknown";
/* 292 */ };
/* 292 */ };
/* 292 */ function logTypeText(type) {
switch (type) {
/* 293 */ case 0:
/* 293 */ return "Message";
/* 293 */ case 1:
return "Warning";
case 2:
/* 294 */ return "Error";
/* 294 */ default:
return "Unknown";
};
};
/* 298 */ function ensureShortCommitId(deployments) {
/* 299 */ return deployments.map(function(deployment) {
/* 300 */ deployment.shortId = deployment.id.substr(0, 10);
/* 300 */ return deployment;
/* 300 */ });
};
/* 301 */ function ensureRepositoryUri(context, _) {
/* 301 */ var siteData, repositoryUri;
/* 301 */ var __frame = {
name: "ensureRepositoryUri",
/* 302 */ line: 314
/* 302 */ };
/* 302 */ return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() {
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 1, 19, function ___(__0, __1) {
siteData = __1;
/* 303 */ repositoryUri = (siteData && site.getRepositoryUri(siteData));
/* 303 */ return (function __$ensureRepositoryUri(__then) {
if (!repositoryUri) {
return site.doSiteGet(context, __cb(_, __frame, 4, 17, function ___(__0, __2) {
siteData = __2;
/* 307 */ repositoryUri = site.getRepositoryUri(siteData);
/* 308 */ __then();
/* 309 */ }, true));
/* 310 */ }
else {
__then();
/* 314 */ }
;
})(function __$ensureRepositoryUri() {
if (repositoryUri) {
context.repositoryAuth = site.getRepositoryAuth(siteData);
return _(null, context.repositoryUri = repositoryUri);
}
/* 315 */ ;
_();
/* 316 */ });
}, true));
/* 317 */ });
/* 318 */ };
/* 318 */ scm.ensureRepositoryUri = ensureRepositoryUri;
/* 319 */ function formatDeployment(deployment) {
var timeProperties = ["end_time","last_success_end_time","received_time","start_time",];
for (var i = 0; (i < timeProperties.length); ++i) {
if (deployment[timeProperties[i]]) {
deployment[timeProperties[i]] = dateTimeText(deployment[timeProperties[i]]);
}
;
};
deployment.complete = (!!deployment.complete).toString();
/* 321 */ deployment.status = (deployment.active ? "Active" : deploymentStatusText(deployment.status));
/* 322 */ deployment.message = deployment.message.replace(/\s*(.*)\s*?/g, "$1");
/* 323 */ delete deployment.active;
delete deployment.status_text;
delete deployment.url;
delete deployment.log_url;
return deployment;
};
function formatLog(log) {
log.hasDetails = !!log.details_url;
/* 326 */ log.log_time = (log.log_time && dateTimeText(log.log_time));
/* 328 */ log.short_time = (log.log_time && log.log_time.replace(/.* +(.*)/g, "$1"));
/* 329 */ log.type = logTypeText(log.type);
/* 330 */ log.shortId = log.id.substr(0, 10);
/* 331 */ delete log.details_url;
/* 332 */ return log;
};
};

Просмотреть файл

@ -0,0 +1,354 @@
/**
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//if (!require('streamline/module')(module)) return;
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')
.description('Commands to manage your git deployments');
function getScmChannel(context) {
var parts = url.parse(context.repositoryUri);
var channel = new Channel({
host: parts.hostname,
port: (parts.port && parseInt(parts.port, 10)) || (/https/i.test(parts.protocol) ? 443 : 80),
auth: context.repositoryAuth
});
var proxyString =
process.env.HTTPS_PROXY ||
process.env.https_proxy ||
process.env.ALL_PROXY ||
process.env.all_proxy;
if (proxyString !== undefined) {
var proxyUrl = url.parse(proxyString);
if (proxyUrl.protocol !== 'http:' &&
proxyUrl.protocol !== 'https:') {
// fall-back parsing support XXX_PROXY=host:port environment variable values
proxyUrl = url.parse('http://' + proxyString);
}
channel = channel.add({ proxy: proxyUrl });
}
return channel;
}
scm.getScmChannel = getScmChannel;
scm.command('list [name]')
.whiteListPowershell()
.usage('[options] [name]')
.description('List your git deployments')
.option('-s, --subscription <id>', 'use the subscription id')
.option('-m, --max <count>', 'limit the maximum number of results')
.execute(function (name, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
maxItems: options.max,
site: {
name: name
}
};
var repositoryUri = ensureRepositoryUri(context, _);
if (repositoryUri) {
listDeployments(context, _);
} else {
log.error('Repository is not setup');
}
});
scm.command('show <commitId> [name]')
.whiteListPowershell()
.usage('[options] <commitId> [name]')
.description('Show your git deployment')
.option('-s, --subscription <id>', 'use the subscription id')
.option('-d, --details', 'display log details')
.execute(function (commitId, name, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
shortId: commitId,
site: {
name: name
}
};
if (!(context.id = cacheUtils.readCommitId(context, _))) {
return log.error('deployment with ' + commitId + ' does not exist');
}
var repositoryUri = ensureRepositoryUri(context, _);
if (repositoryUri) {
var deployment = scm.doDeploymentGet(context, _);
site.logEachData('info', deployment);
if (options.details) {
showLogDetails(context, _);
} else {
log.help('To see more details, specify -d or --details option');
}
} else {
log.error('Repository is not setup');
}
});
scm.command('redeploy <commitId> [name]')
.whiteListPowershell()
.usage('[options] <commitId> [name]')
.description('Redeploy your git deployment')
.option('-s, --subscription <id>', 'use the subscription id')
.execute(function (commitId, name, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
shortId: commitId,
site: {
name: name
}
};
if (!(context.id = cacheUtils.readCommitId(context, _))) {
return log.error('deployment with ' + commitId + ' does not exist');
}
var repositoryUri = ensureRepositoryUri(context, _);
if (repositoryUri) {
if (!site.confirm('Reploy deployment with ' + context.shortId + ' id? (y/n) ', _)) {
return;
}
scm.doDeploymentPut(context, _);
listDeployments(context, _);
} else {
log.error('Repository is not setup');
}
});
scm.doDeploymentsGet = function (context, _) {
var maxItems = parseInt(context.maxItems, 10);
if (!maxItems || maxItems <= 0) {
maxItems = 20;
}
var channel = getScmChannel(context)
.path('deployments')
.query('$orderby', 'ReceivedTime desc')
.query('$top', maxItems);
var progress = cli.progress('Enumerating deployments');
try {
var deployments = ensureShortCommitId(channel.GET(_));
cacheUtils.saveCommitIds(context, deployments, _);
return deployments.map(formatDeployment);
} finally {
progress.end();
}
};
scm.doDeploymentGet = function (context, _) {
var channel = getScmChannel(context)
.path('deployments')
.path(context.id);
var progress = cli.progress('Retrieving deployment info');
try {
return formatDeployment(channel.GET(_));
} finally {
progress.end();
}
};
scm.doDeploymentPut = function (context, _) {
var channel = getScmChannel(context)
.path('deployments')
.path(context.id);
var progress = cli.progress('Redeploying deployment');
try {
return channel.PUT(null, _);
} finally {
progress.end();
}
};
scm.doLogGet = function (context, _) {
var channel = getScmChannel(context)
.path('deployments')
.path(context.id)
.path('log');
var progress = cli.progress('Retrieving deployment log info');
try {
var logs = channel.GET(_);
return logs.map(formatLog);
} finally {
progress.end();
}
};
function listDeployments(context, _) {
var deployments = scm.doDeploymentsGet(context, _);
var authorLength = 0, messageLength = 0;
log.table(deployments, function (row, deployment) {
row.cell('Time', deployment.start_time);
row.cell('Commit id', deployment.shortId);
row.cell('Status', deployment.status);
authorLength = Math.max(deployment.author.length, authorLength);
row.cell('Author', deployment.author, null, Math.min(authorLength, 15));
messageLength = Math.max(deployment.message.length, messageLength);
row.cell('Message', deployment.message, null, Math.min(messageLength, 40));
});
}
function showLogDetails(context, _) {
var results,
logs = scm.doLogGet(context, _);
if (logs && logs.length) {
var progress = cli.progress('Retrieving log details');
try {
results = async.map(logs, function (log, _) {
if (log.hasDetails) {
var details = getScmChannel(context)
.path('deployments')
.path(context.id)
.path('log')
.path(log.id)
.GET(_);
return details.map(formatLog);
}
}, _);
} finally {
progress.end();
}
for (var i = 0; i < logs.length; ++i) {
displayLog(logs[i]);
if (results[i]) {
var details = results[i];
for (var j = 0; j < details.length; ++j) {
displayLog(details[j]);
}
}
}
} else {
log.info('deployment has no detail');
}
}
function displayLog(item) {
if (item.type === 'Warning') {
log.warn(item.short_time + ' ' + item.message);
} else if (item.type === 'Error') {
log.error(item.short_time + ' ' + item.message);
} else {
log.data(item.short_time + ' ' + item.message);
}
}
function fromJsonDate(str) {
return eval(str.replace(/\/Date\((.*)[+].*\)\//gi, "new Date($1)"));
}
function formatDate(dt) {
var date = dt.getDate(),
month = dt.getMonth();
date = (date < 10 ? "0" : "") + date;
month = (month < 10 ? "0" : "") + month;
return dt.getFullYear() + "-" + month + "-" + date + " " + dt.toLocaleTimeString();
}
function dateTimeText(str) {
return formatDate(fromJsonDate(str));
}
function deploymentStatusText(status) {
switch (status) {
case 0: return 'Pending';
case 1: return 'Building';
case 2: return 'Deploying';
case 3: return 'Failed';
case 4: return 'Success';
default: return 'Unknown';
}
}
function logTypeText(type) {
switch (type) {
case 0: return 'Message';
case 1: return 'Warning';
case 2: return 'Error';
default: return 'Unknown';
}
}
function ensureShortCommitId(deployments) {
return deployments.map(function (deployment) {
deployment.shortId = deployment.id.substr(0, 10);
return deployment;
});
}
function ensureRepositoryUri(context, _) {
var siteData = site.lookupSiteNameAndWebSpace(context, _);
var repositoryUri = siteData && site.getRepositoryUri(siteData);
if (!repositoryUri) {
siteData = site.doSiteGet(context, _);
repositoryUri = site.getRepositoryUri(siteData);
}
if (repositoryUri) {
context.repositoryAuth = site.getRepositoryAuth(siteData);
return context.repositoryUri = repositoryUri;
}
}
scm.ensureRepositoryUri = ensureRepositoryUri;
function formatDeployment(deployment) {
var timeProperties = ['end_time', 'last_success_end_time', 'received_time', 'start_time'];
for (var i = 0; i < timeProperties.length; ++i) {
if (deployment[timeProperties[i]]) {
deployment[timeProperties[i]] = dateTimeText(deployment[timeProperties[i]]);
}
}
deployment.complete = (!!deployment.complete).toString();
deployment.status = deployment.active ? 'Active' : deploymentStatusText(deployment.status);
deployment.message = deployment.message.replace(/\s*(.*)\s*?/g, "$1");
delete deployment.active;
delete deployment.status_text;
delete deployment.url;
delete deployment.log_url;
return deployment;
}
function formatLog(log) {
log.hasDetails = !!log.details_url;
log.log_time = log.log_time && dateTimeText(log.log_time);
log.short_time = log.log_time && log.log_time.replace(/.* +(.*)/g, "$1");
log.type = logTypeText(log.type);
log.shortId = log.id.substr(0, 10);
delete log.details_url;
return log;
}
};

113
lib/cli/commands/log.js Normal file
Просмотреть файл

@ -0,0 +1,113 @@
/*** Generated by streamline 0.2.5 - DO NOT EDIT ***/
var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch,__propagate=__rt.__propagate,__trap=__rt.__trap,__future=__rt.__future,__setEF=__rt.__setEF,__g=__rt.__g;
/* 1 */ var common = require("../common");
/* 20 */ var fs = require("fs");
/* 21 */ var path = require("path");
/* 22 */ var url = require("url");
/* 23 */ var crypto = require("crypto");
/* 24 */ var pfx2pem = require("../../util/certificates/pkcs").pfx2pem;
/* 25 */ var Channel = require("../channel");
/* 26 */ var async = require("async");
/* 27 */ var child_process = require("child_process");
/* 28 */ var utils = require("../utils");
/* 29 */ var constants = require("../constants");
/* 30 */ var cacheUtils = require("../cacheUtils");
/* 32 */ exports.init = function(cli) {
/* 34 */ var log = cli.output;
/* 35 */ var site = cli.category("site");
/* 36 */ var scm = site.category("deployment");
/* 37 */ var diagnostic = site.category("log").description("Commands to download diagnostic log");
/* 40 */ diagnostic.command("download [name]").whiteListPowershell().description("Download diagnostic log").option("-s, --subscription <id>", "use the subscription id").option("-o, --output <path>", "output path, default is local folder").execute(function __1(name, options, _) {
var context, repositoryUri, buf;
var __frame = {
name: "__1",
line: 45
};
return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
/* 46 */ context = {
/* 47 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 48 */ path: (options.output || ""),
/* 49 */ site: {
/* 50 */ name: name
}
};
/* 54 */ if (!(/[.]zip$/i.test(context.path))) {
/* 55 */ context.path = path.join(context.path, "diagnostics.zip");
}
;
return (function __$__1(__then) {
/* 58 */ if (path.existsSync(context.path)) {
/* 59 */ return site.confirm((("Replace existing " + context.path) + "? (y/n) "), __cb(_, __frame, 14, 13, function ___(__0, __2) {
/* 59 */ var __1 = !__2;
return (function __$__1(__then) {
if (__1) {
return _(null);
}
else {
__then();
}
;
})(__then);
}, true));
}
else {
__then();
}
;
})(function __$__1() {
/* 64 */ return scm.ensureRepositoryUri(context, __cb(_, __frame, 19, 26, function ___(__0, __3) {
repositoryUri = __3;
return (function __$__1(__then) {
/* 65 */ if (repositoryUri) {
/* 66 */ return doDownloadDiagnostic(context, __cb(_, __frame, 21, 18, function ___(__0, __4) {
buf = __4;
/* 67 */ log.info(("Writing to " + context.path));
/* 68 */ return fs.writeFile(context.path, buf, __cb(_, __frame, 23, 8, __then, true));
}, true));
}
else {
/* 70 */ log.error("Repository is not setup");
__then();
}
;
})(_);
}, true));
});
});
});
/* 74 */ function doDownloadDiagnostic(context, _) {
var channel, progress;
var __frame = {
name: "doDownloadDiagnostic",
line: 74
};
return __func(_, this, arguments, doDownloadDiagnostic, 1, __frame, function __$doDownloadDiagnostic() {
/* 76 */ channel = scm.getScmChannel(context).path("dump");
/* 77 */ progress = cli.progress("Downloading diagnostic log");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$doDownloadDiagnostic() {
/* 79 */ return channel.GET(__cb(_, __frame, 5, 13, _, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$doDownloadDiagnostic() {
/* 81 */ progress.end();
__then();
});
})(function ___() {
__tryCatch(_, function ___() {
if (__cont) {
__then();
} else {
_(__e, __r);
};
});
});
});
})(function ___() {
__tryCatch(_, _);
});
});
};
};

84
lib/cli/commands/log_.js Normal file
Просмотреть файл

@ -0,0 +1,84 @@
/**
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//if (!require('streamline/module')(module)) return;
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 diagnostic = site.category('log')
.description('Commands to download diagnostic log');
diagnostic.command('download [name]')
.whiteListPowershell()
.description('Download diagnostic log')
.option('-s, --subscription <id>', 'use the subscription id')
.option('-o, --output <path>', 'output path, default is local folder')
.execute(function (name, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
path: options.output || '',
site: {
name: name
}
};
if (!(/[.]zip$/i.test(context.path))) {
context.path = path.join(context.path, 'diagnostics.zip');
}
if (path.existsSync(context.path)) {
if (!site.confirm('Replace existing ' + context.path + '? (y/n) ', _)) {
return;
}
}
var repositoryUri = scm.ensureRepositoryUri(context, _);
if (repositoryUri) {
var buf = doDownloadDiagnostic(context, _);
log.info('Writing to ' + context.path);
fs.writeFile(context.path, buf, _);
} else {
log.error('Repository is not setup');
}
});
function doDownloadDiagnostic(context, _) {
var channel = scm.getScmChannel(context)
.path('dump');
var progress = cli.progress('Downloading diagnostic log');
try {
return channel.GET(_);
} finally {
progress.end();
}
}
};

Просмотреть файл

@ -73,6 +73,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
/* 94 */ callback(undefined, x);
});
};
/* 96 */ site.confirm = confirm;
/* 98 */ site.command("create [name]").whiteListPowershell().description("Create a new web site and local directory").option("-s, --subscription <id>", "use the subscription id").option("--location <location>", "the geographic region to create the website").option("--hostname <hostname>", "custom host name to use").option("--git", "configure git on web site and local folder").execute(function __2(nameArg, options, _) {
var context;
/* 127 */ function promptForSiteName(_) {
@ -525,7 +526,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
});
});
/* 341 */ site.command("show [name]").whiteListPowershell().description("Show details for a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __5(name, options, _) {
var context, result, repositoryUri, i, pair;
var context, result, repositoryUri;
var __frame = {
name: "__5",
line: 345
@ -560,44 +561,36 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
result = __3;
/* 364 */ logEachData("Site", result[0]);
/* 365 */ logEachData("Config", result[1]);
/* 367 */ repositoryUri = null;
/* 368 */ for (i = 0; (i < result[0].SiteProperties.Properties.NameValuePair.length); ++i) {
/* 369 */ pair = result[0].SiteProperties.Properties.NameValuePair[i];
/* 370 */ if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) {
/* 371 */ repositoryUri = (!pair.Value["@"] && pair.Value);
/* 372 */ break;
}
;
};
/* 375 */ log.data("Repository", (repositoryUri ? ((((clean(repositoryUri) + "/") + context.site.name) + ".git")) : ""));
/* 367 */ repositoryUri = getRepositoryUri(result[0]);
/* 368 */ log.data("Repository", (repositoryUri ? ((((repositoryUri + "/") + context.site.name) + ".git")) : ""));
_();
}, true));
}, true));
});
});
/* 378 */ function lookupSiteName(context, _) {
/* 371 */ function lookupSiteName(context, _) {
var cfg;
var __frame = {
name: "lookupSiteName",
line: 378
line: 371
};
return __func(_, this, arguments, lookupSiteName, 1, __frame, function __$lookupSiteName() {
/* 379 */ if ((context.site.name !== undefined)) {
/* 372 */ if ((context.site.name !== undefined)) {
return _(null);
}
;
/* 384 */ return site.readConfig(__cb(_, __frame, 6, 14, function ___(__0, __1) {
/* 377 */ return site.readConfig(__cb(_, __frame, 6, 14, function ___(__0, __1) {
cfg = __1;
/* 385 */ if (((cfg !== undefined) && cfg.name)) {
/* 387 */ context.site.name = cfg.name;
/* 388 */ context.site.webspace = cfg.webspace;
/* 378 */ if ((cfg && cfg.name)) {
/* 380 */ context.site.name = cfg.name;
/* 381 */ context.site.webspace = cfg.webspace;
return _(null);
}
;
/* 392 */ return prompt("Web site name: ", __cb(_, __frame, 14, 24, function ___(__0, __2) {
/* 392 */ context.site.name = __2;
/* 394 */ if (!context.site.name) {
/* 395 */ return _(new Error("Invalid site name"));
/* 385 */ return prompt("Web site name: ", __cb(_, __frame, 14, 24, function ___(__0, __2) {
/* 385 */ context.site.name = __2;
/* 387 */ if (!context.site.name) {
/* 388 */ return _(new Error("Invalid site name"));
}
;
_();
@ -605,73 +598,100 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
}, true));
});
};
/* 399 */ function lookupSiteWebSpace(context, _) {
/* 392 */ function lookupSiteWebSpace(context, _) {
var sites, index;
var __frame = {
name: "lookupSiteWebSpace",
line: 399
line: 392
};
return __func(_, this, arguments, lookupSiteWebSpace, 1, __frame, function __$lookupSiteWebSpace() {
/* 400 */ log.verbose("Attempting to locate site ", context.site.name);
/* 401 */ return site.doSitesGet(context, __cb(_, __frame, 2, 16, function ___(__0, __1) {
/* 393 */ log.verbose("Attempting to locate site ", context.site.name);
/* 394 */ return site.doSitesGet(context, __cb(_, __frame, 2, 16, function ___(__0, __1) {
sites = __1;
/* 402 */ for (index in sites) {
/* 403 */ if (utils.ignoreCaseEquals(sites[index].Name, context.site.name)) {
/* 404 */ log.verbose("Site located at ", sites[index].WebSpace);
/* 405 */ context.site.webspace = sites[index].WebSpace;
/* 395 */ for (index in sites) {
/* 396 */ if (utils.ignoreCaseEquals(sites[index].Name, context.site.name)) {
/* 397 */ log.verbose("Site located at ", sites[index].WebSpace);
/* 398 */ context.site.webspace = sites[index].WebSpace;
}
;
};
/* 408 */ if ((context.site.webspace === undefined)) {
/* 409 */ return _(new Error(("Unable to locate site named " + context.site.name)));
/* 401 */ if ((context.site.webspace === undefined)) {
/* 402 */ return _(new Error(("Unable to locate site named " + context.site.name)));
}
;
_();
}, true));
});
};
/* 413 */ function lookupSiteNameAndWebSpace(context, _) {
/* 406 */ function lookupSiteNameAndWebSpace(context, _) {
var cache;
var __frame = {
name: "lookupSiteNameAndWebSpace",
line: 413
line: 406
};
return __func(_, this, arguments, lookupSiteNameAndWebSpace, 1, __frame, function __$lookupSiteNameAndWebSpace() {
/* 414 */ return lookupSiteName(context, __cb(_, __frame, 1, 4, function __$lookupSiteNameAndWebSpace() {
/* 415 */ return cacheUtils.readSite(context, __cb(_, __frame, 2, 16, function ___(__0, __1) {
/* 407 */ return lookupSiteName(context, __cb(_, __frame, 1, 4, function __$lookupSiteNameAndWebSpace() {
/* 408 */ return cacheUtils.readSite(context, __cb(_, __frame, 2, 16, function ___(__0, __1) {
cache = __1;
/* 416 */ if ((cache || context.site.webspace)) {
/* 417 */ context.site.webspace = (((cache && cache.WebSpace)) || context.site.webspace);
/* 418 */ return _(null, cache);
/* 409 */ if ((cache || context.site.webspace)) {
/* 410 */ context.site.webspace = (((cache && cache.WebSpace)) || context.site.webspace);
/* 411 */ return _(null, cache);
}
;
/* 420 */ return lookupSiteWebSpace(context, __cb(_, __frame, 7, 4, _, true));
/* 413 */ return lookupSiteWebSpace(context, __cb(_, __frame, 7, 4, _, true));
}, true));
}, true));
});
};
/* 423 */ site.command("delete [name]").whiteListPowershell().description("Delete a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __6(name, options, _) {
/* 415 */ site.lookupSiteNameAndWebSpace = lookupSiteNameAndWebSpace;
/* 417 */ function getRepositoryUri(siteData) {
/* 418 */ for (var i = 0; (i < siteData.SiteProperties.Properties.NameValuePair.length); ++i) {
/* 419 */ var pair = siteData.SiteProperties.Properties.NameValuePair[i];
/* 420 */ if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) {
/* 421 */ return (((typeof pair.Value === "string")) ? pair.Value : null);
}
;
};
};
/* 425 */ site.getRepositoryUri = getRepositoryUri;
/* 427 */ function getRepositoryAuth(siteData) {
/* 428 */ var userName, password;
/* 429 */ for (var i = 0; (i < siteData.SiteProperties.Properties.NameValuePair.length); ++i) {
/* 430 */ var pair = siteData.SiteProperties.Properties.NameValuePair[i];
/* 431 */ if (utils.ignoreCaseEquals(pair.Name, "PublishingUsername")) {
/* 432 */ userName = pair.Value;
}
/* 433 */ else if (utils.ignoreCaseEquals(pair.Name, "PublishingPassword")) {
/* 434 */ password = pair.Value;
}
;
};
/* 437 */ return (userName && (((userName + ":") + password)));
};
/* 439 */ site.getRepositoryAuth = getRepositoryAuth;
/* 441 */ site.command("delete [name]").whiteListPowershell().description("Delete a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __6(name, options, _) {
var context, progress, result;
var __frame = {
name: "__6",
line: 427
line: 445
};
return __func(_, this, arguments, __6, 2, __frame, function __$__6() {
/* 428 */ context = {
/* 429 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 430 */ site: {
/* 431 */ name: name
/* 446 */ context = {
/* 447 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 448 */ site: {
/* 449 */ name: name
}
};
/* 435 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__6() {
/* 437 */ log.info("Deleting site", context.site.name);
/* 439 */ progress = cli.progress("Deleting site");
/* 453 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__6() {
/* 455 */ log.info("Deleting site", context.site.name);
/* 457 */ progress = cli.progress("Deleting site");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$__6() {
/* 448 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).DELETE(__cb(_, __frame, 21, 25, function ___(__0, __1) {
/* 466 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).DELETE(__cb(_, __frame, 21, 25, function ___(__0, __1) {
result = __1;
/* 449 */ return cacheUtils.deleteSite(context, __cb(_, __frame, 22, 12, function __$__6() {
/* 467 */ return cacheUtils.deleteSite(context, __cb(_, __frame, 22, 12, function __$__6() {
_(null, null, true);
}, true));
}, true));
@ -679,7 +699,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$__6() {
/* 452 */ progress.end();
/* 470 */ progress.end();
__then();
});
})(function ___() {
@ -694,47 +714,47 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
});
})(function ___() {
__tryCatch(_, function __$__6() {
/* 454 */ log.info((("Site " + context.site.name) + " has been deleted"));
/* 472 */ log.info((("Site " + context.site.name) + " has been deleted"));
_();
});
});
}, true));
});
});
/* 458 */ site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __7(name, options, _) {
/* 476 */ site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __7(name, options, _) {
var context, progress, result;
var __frame = {
name: "__7",
line: 462
line: 480
};
return __func(_, this, arguments, __7, 2, __frame, function __$__7() {
/* 463 */ context = {
/* 464 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 465 */ site: {
/* 466 */ name: name
/* 481 */ context = {
/* 482 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 483 */ site: {
/* 484 */ name: name
}
};
/* 470 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__7() {
/* 472 */ log.info("Starting site", context.site.name);
/* 474 */ progress = cli.progress("Updating site state");
/* 488 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__7() {
/* 490 */ log.info("Starting site", context.site.name);
/* 492 */ progress = cli.progress("Updating site state");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$__7() {
/* 484 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) {
/* 485 */ req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
/* 486 */ req.write("<HostNames>");
/* 487 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 488 */ req.write((context.site.name + cli.category("account").hostNameSuffix()));
/* 489 */ req.write("</string>");
/* 490 */ req.write("</HostNames>");
/* 491 */ req.write("<Name>");
/* 492 */ req.write(context.site.name);
/* 493 */ req.write("</Name>");
/* 494 */ req.write("<State>");
/* 495 */ req.write("Running");
/* 496 */ req.write("</State>");
/* 497 */ req.write("</Site>");
/* 499 */ req.end();
/* 502 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) {
/* 503 */ req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
/* 504 */ req.write("<HostNames>");
/* 505 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 506 */ req.write((context.site.name + cli.category("account").hostNameSuffix()));
/* 507 */ req.write("</string>");
/* 508 */ req.write("</HostNames>");
/* 509 */ req.write("<Name>");
/* 510 */ req.write(context.site.name);
/* 511 */ req.write("</Name>");
/* 512 */ req.write("<State>");
/* 513 */ req.write("Running");
/* 514 */ req.write("</State>");
/* 515 */ req.write("</Site>");
/* 517 */ req.end();
}, __cb(_, __frame, 22, 25, function ___(__0, __1) {
result = __1;
_(null, null, true);
@ -743,7 +763,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$__7() {
/* 503 */ progress.end();
/* 521 */ progress.end();
__then();
});
})(function ___() {
@ -758,47 +778,47 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
});
})(function ___() {
__tryCatch(_, function __$__7() {
/* 506 */ log.info((("Site " + context.site.name) + " has been started"));
/* 524 */ log.info((("Site " + context.site.name) + " has been started"));
_();
});
});
}, true));
});
});
/* 509 */ site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __8(name, options, _) {
/* 527 */ site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __8(name, options, _) {
var context, progress, result;
var __frame = {
name: "__8",
line: 513
line: 531
};
return __func(_, this, arguments, __8, 2, __frame, function __$__8() {
/* 514 */ context = {
/* 515 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 516 */ site: {
/* 517 */ name: name
/* 532 */ context = {
/* 533 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
/* 534 */ site: {
/* 535 */ name: name
}
};
/* 521 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__8() {
/* 523 */ log.info("Stopping site", context.site.name);
/* 525 */ progress = cli.progress("Updating site state");
/* 539 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__8() {
/* 541 */ log.info("Stopping site", context.site.name);
/* 543 */ progress = cli.progress("Updating site state");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$__8() {
/* 535 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) {
/* 536 */ req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
/* 537 */ req.write("<HostNames>");
/* 538 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 539 */ req.write((context.site.name + cli.category("account").hostNameSuffix()));
/* 540 */ req.write("</string>");
/* 541 */ req.write("</HostNames>");
/* 542 */ req.write("<Name>");
/* 543 */ req.write(context.site.name);
/* 544 */ req.write("</Name>");
/* 545 */ req.write("<State>");
/* 546 */ req.write("Stopped");
/* 547 */ req.write("</State>");
/* 548 */ req.write("</Site>");
/* 550 */ req.end();
/* 553 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) {
/* 554 */ req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
/* 555 */ req.write("<HostNames>");
/* 556 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 557 */ req.write((context.site.name + cli.category("account").hostNameSuffix()));
/* 558 */ req.write("</string>");
/* 559 */ req.write("</HostNames>");
/* 560 */ req.write("<Name>");
/* 561 */ req.write(context.site.name);
/* 562 */ req.write("</Name>");
/* 563 */ req.write("<State>");
/* 564 */ req.write("Stopped");
/* 565 */ req.write("</State>");
/* 566 */ req.write("</Site>");
/* 568 */ req.end();
}, __cb(_, __frame, 22, 25, function ___(__0, __1) {
result = __1;
_(null, null, true);
@ -807,7 +827,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$__8() {
/* 554 */ progress.end();
/* 572 */ progress.end();
__then();
});
})(function ___() {
@ -822,61 +842,61 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
});
})(function ___() {
__tryCatch(_, function __$__8() {
/* 557 */ log.info((("Site " + context.site.name) + " has been stopped"));
/* 575 */ log.info((("Site " + context.site.name) + " has been stopped"));
_();
});
});
}, true));
});
});
/* 564 */ site.readConfig = function site_readConfig__9(_) {
/* 582 */ site.readConfig = function site_readConfig__9(_) {
var __frame = {
name: "site_readConfig__9",
line: 564
line: 582
};
return __func(_, this, arguments, site_readConfig__9, 0, __frame, function __$site_readConfig__9() {
/* 566 */ return site.readConfigValue("azure.site.name", __cb(_, __frame, 2, 12, function ___(__0, __2) {
/* 567 */ return site.readConfigValue("azure.site.webspace", __cb(_, __frame, 3, 16, function ___(__0, __3) {
/* 565 */ var __1 = {
/* 566 */ name: __2,
/* 567 */ webspace: __3
/* 584 */ return site.readConfigValue("azure.site.name", __cb(_, __frame, 2, 12, function ___(__0, __2) {
/* 585 */ return site.readConfigValue("azure.site.webspace", __cb(_, __frame, 3, 16, function ___(__0, __3) {
/* 583 */ var __1 = {
/* 584 */ name: __2,
/* 585 */ webspace: __3
};
return _(null, __1);
}, true));
}, true));
});
};
/* 571 */ site.writeConfig = function site_writeConfig__10(cfg, _) {
/* 589 */ site.writeConfig = function site_writeConfig__10(cfg, _) {
var __frame = {
name: "site_writeConfig__10",
line: 571
line: 589
};
return __func(_, this, arguments, site_writeConfig__10, 1, __frame, function __$site_writeConfig__10() {
/* 572 */ return site.writeConfigValue("azure.site.name", cfg.name, __cb(_, __frame, 1, 4, function __$site_writeConfig__10() {
/* 573 */ return site.writeConfigValue("azure.site.webspace", cfg.webspace, __cb(_, __frame, 2, 4, _, true));
/* 590 */ return site.writeConfigValue("azure.site.name", cfg.name, __cb(_, __frame, 1, 4, function __$site_writeConfig__10() {
/* 591 */ return site.writeConfigValue("azure.site.webspace", cfg.webspace, __cb(_, __frame, 2, 4, _, true));
}, true));
});
};
/* 576 */ site.readConfigValue = function site_readConfigValue__11(name, _) {
/* 594 */ site.readConfigValue = function site_readConfigValue__11(name, _) {
var result;
var __frame = {
name: "site_readConfigValue__11",
line: 576
line: 594
};
return __func(_, this, arguments, site_readConfigValue__11, 1, __frame, function __$site_readConfigValue__11() {
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$site_readConfigValue__11() {
/* 578 */ return exec(("git config --get " + name), __cb(_, __frame, 2, 19, function ___(__0, __1) {
/* 596 */ return exec(("git config --get " + name), __cb(_, __frame, 2, 19, function ___(__0, __1) {
result = __1;
/* 579 */ return _(null, ((result.stdout + result.stderr)).trim());
/* 597 */ return _(null, ((result.stdout + result.stderr)).trim());
}, true));
});
})(function ___(err, __result) {
__tryCatch(_, function __$site_readConfigValue__11() {
if (err) {
/* 582 */ log.silly("Unable to read config", err);
/* 583 */ return _(null, "");
/* 600 */ log.silly("Unable to read config", err);
/* 601 */ return _(null, "");
}
else {
_(null, __result);
@ -889,86 +909,86 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
});
});
};
/* 587 */ site.writeConfigValue = function site_writeConfigValue__12(name, value, _) {
/* 605 */ site.writeConfigValue = function site_writeConfigValue__12(name, value, _) {
var __frame = {
name: "site_writeConfigValue__12",
line: 587
line: 605
};
return __func(_, this, arguments, site_writeConfigValue__12, 2, __frame, function __$site_writeConfigValue__12() {
/* 588 */ return exec(((("git config " + name) + " ") + value), __cb(_, __frame, 1, 4, _, true));
/* 606 */ return exec(((("git config " + name) + " ") + value), __cb(_, __frame, 1, 4, _, true));
});
};
/* 595 */ site.doSitesPost = function(options, callback) {
/* 596 */ log.info("Creating a new web site at ", (options.site.name + cli.category("account").hostNameSuffix()));
/* 597 */ log.verbose("Subscription", options.subscription);
/* 598 */ log.verbose("Webspace", options.site.webspace);
/* 599 */ log.verbose("Site", options.site.name);
/* 601 */ var progress = cli.progress("Sending site information");
/* 602 */ try {
/* 603 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").header("Content-Type", "application/xml").POST(writers.Site.xml(options.site), function(err, result) {
/* 613 */ if (err) {
/* 614 */ logError("Failed to create site", err);
}
/* 615 */ else {
/* 616 */ return cacheUtils.saveSite(options, result, function(err) {
/* 617 */ log.info("Created website at ", clean(result).HostNames);
/* 618 */ log.verbose("Site", clean(result));
/* 619 */ callback(err, result);
});
}
;
/* 622 */ callback(err, result);
});
/* 625 */ } finally {
/* 626 */ progress.end();
/* 613 */ site.doSitesPost = function(options, callback) {
/* 614 */ log.info("Creating a new web site at ", (options.site.name + cli.category("account").hostNameSuffix()));
/* 615 */ log.verbose("Subscription", options.subscription);
/* 616 */ log.verbose("Webspace", options.site.webspace);
/* 617 */ log.verbose("Site", options.site.name);
/* 619 */ var progress = cli.progress("Sending site information");
/* 620 */ var cb = function(err, result) {
/* 621 */ progress.end();
/* 622 */ return (callback && callback(err, result));
};
/* 625 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").header("Content-Type", "application/xml").POST(writers.Site.xml(options.site), function(err, result) {
/* 635 */ if (err) {
/* 636 */ logError("Failed to create site", err);
}
/* 637 */ else {
/* 638 */ return cacheUtils.saveSite(options, result, function(err) {
/* 639 */ log.info("Created website at ", clean(result).HostNames);
/* 640 */ log.verbose("Site", clean(result));
/* 641 */ return cb(err, result);
});
}
;
/* 644 */ return cb(err, result);
});
};
/* 630 */ site.doRepositoryPost = function(options, callback) {
/* 631 */ log.info("Initializing remote Azure repository");
/* 632 */ log.verbose("Subscription", options.subscription);
/* 633 */ log.verbose("Webspace", options.site.webspace);
/* 634 */ log.verbose("Site", options.site.name);
/* 636 */ var progress = cli.progress("Updating site information");
/* 637 */ try {
/* 638 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").POST("", function(err, result) {
/* 649 */ if (err) {
/* 650 */ logError("Failed to initialize repository", err);
}
/* 651 */ else {
/* 652 */ log.info("Repository initialized");
}
;
/* 654 */ callback(err, result);
});
/* 657 */ } finally {
/* 658 */ progress.end();
/* 648 */ site.doRepositoryPost = function(options, callback) {
/* 649 */ log.info("Initializing remote Azure repository");
/* 650 */ log.verbose("Subscription", options.subscription);
/* 651 */ log.verbose("Webspace", options.site.webspace);
/* 652 */ log.verbose("Site", options.site.name);
/* 654 */ var progress = cli.progress("Updating site information");
/* 655 */ var cb = function(err, result) {
/* 656 */ progress.end();
/* 657 */ return (callback && callback(err, result));
};
/* 659 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").POST("", function(err, result) {
/* 670 */ if (err) {
/* 671 */ logError("Failed to initialize repository", err);
}
/* 672 */ else {
/* 673 */ log.info("Repository initialized");
}
;
/* 675 */ return cb(err, result);
});
};
/* 662 */ site.doSpacesGet = function site_doSpacesGet__13(options, _) {
/* 679 */ site.doSpacesGet = function site_doSpacesGet__13(options, _) {
var progress, result, spaces;
var __frame = {
name: "site_doSpacesGet__13",
line: 662
line: 679
};
return __func(_, this, arguments, site_doSpacesGet__13, 1, __frame, function __$site_doSpacesGet__13() {
/* 663 */ log.verbose("Subscription", options.subscription);
/* 665 */ progress = cli.progress("Enumerating locations");
/* 680 */ log.verbose("Subscription", options.subscription);
/* 682 */ progress = cli.progress("Enumerating locations");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$site_doSpacesGet__13() {
/* 672 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").GET(__cb(_, __frame, 10, 19, function ___(__0, __1) {
/* 689 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").GET(__cb(_, __frame, 10, 19, function ___(__0, __1) {
result = __1;
/* 674 */ log.json("silly", result);
/* 675 */ spaces = toArray(result.WebSpace);
/* 676 */ return cacheUtils.saveSpaces(options, spaces, __cb(_, __frame, 14, 6, function __$site_doSpacesGet__13() {
/* 677 */ return _(null, spaces);
/* 691 */ log.json("silly", result);
/* 692 */ spaces = toArray(result.WebSpace);
/* 693 */ return cacheUtils.saveSpaces(options, spaces, __cb(_, __frame, 14, 6, function __$site_doSpacesGet__13() {
/* 694 */ return _(null, spaces);
}, true));
}, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$site_doSpacesGet__13() {
/* 680 */ progress.end();
/* 697 */ progress.end();
__then();
});
})(function ___() {
@ -986,46 +1006,46 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
});
});
};
/* 684 */ site.doSitesGet = function site_doSitesGet__14(options, _) {
/* 701 */ site.doSitesGet = function site_doSitesGet__14(options, _) {
var spaces, channel, progress, result, sites;
var __frame = {
name: "site_doSitesGet__14",
line: 684
line: 701
};
return __func(_, this, arguments, site_doSitesGet__14, 1, __frame, function __$site_doSitesGet__14() {
/* 685 */ log.verbose("Subscription", options.subscription);
/* 687 */ return site.doSpacesGet(options, __cb(_, __frame, 3, 17, function ___(__0, __2) {
/* 702 */ log.verbose("Subscription", options.subscription);
/* 704 */ return site.doSpacesGet(options, __cb(_, __frame, 3, 17, function ___(__0, __2) {
spaces = __2;
/* 692 */ channel = getChannel().path(options.subscription).path("services").path("webspaces");
/* 694 */ progress = cli.progress("Enumerating sites");
/* 709 */ channel = getChannel().path(options.subscription).path("services").path("webspaces");
/* 711 */ progress = cli.progress("Enumerating sites");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$site_doSitesGet__14() {
/* 696 */ return async.map(spaces, function __1(webspace, _) {
/* 713 */ return async.map(spaces, function __1(webspace, _) {
var __frame = {
name: "__1",
line: 698
line: 715
};
return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
/* 704 */ return channel.path(webspace.Name).path("sites").path("").query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(__cb(_, __frame, 6, 25, _, true));
/* 721 */ return channel.path(webspace.Name).path("sites").path("").query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(__cb(_, __frame, 6, 25, _, true));
});
}, __cb(_, __frame, 12, 19, function ___(__0, __3) {
result = __3;
/* 708 */ sites = [];
/* 709 */ result.forEach(function(item) {
/* 710 */ sites = sites.concat(toArray(item.Site));
/* 725 */ sites = [];
/* 726 */ result.forEach(function(item) {
/* 727 */ sites = sites.concat(toArray(item.Site));
});
/* 712 */ result = sites;
/* 714 */ log.json("verbose", sites);
/* 715 */ return cacheUtils.saveSites(options, result, __cb(_, __frame, 31, 6, function __$site_doSitesGet__14() {
/* 716 */ return _(null, sites);
/* 729 */ result = sites;
/* 731 */ log.json("verbose", sites);
/* 732 */ return cacheUtils.saveSites(options, result, __cb(_, __frame, 31, 6, function __$site_doSitesGet__14() {
/* 733 */ return _(null, sites);
}, true));
}, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$site_doSitesGet__14() {
/* 719 */ progress.end();
/* 736 */ progress.end();
__then();
});
})(function ___() {
@ -1044,84 +1064,84 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
}, true));
});
};
/* 723 */ site.doSiteGet = function(options, callback) {
/* 724 */ var progress = cli.progress("Retrieving site information");
/* 725 */ try {
/* 726 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(function(err, result) {
/* 736 */ if (err) {
/* 737 */ logError("Failed to get site info", err);
/* 738 */ if ((err.Code === "NotFound")) {
/* 739 */ return cacheUtils.deleteSite(options, function() {
/* 740 */ callback(err, result);
});
}
;
}
/* 743 */ else {
/* 744 */ return cacheUtils.saveSite(options, result, function(err) {
/* 745 */ log.verbose("Site", clean(result));
/* 746 */ callback(err, result);
/* 740 */ site.doSiteGet = function(options, callback) {
/* 741 */ var progress = cli.progress("Retrieving site information");
/* 742 */ var cb = function(err, result) {
/* 743 */ progress.end();
/* 744 */ return (callback && callback(err, result));
};
/* 746 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(function(err, result) {
/* 756 */ if (err) {
/* 757 */ logError("Failed to get site info", err);
/* 758 */ if ((err.Code === "NotFound")) {
/* 759 */ return cacheUtils.deleteSite(options, function() {
/* 760 */ return cb(err, result);
});
}
;
/* 749 */ callback(err, result);
});
/* 752 */ } finally {
/* 753 */ progress.end();
};
}
/* 763 */ else {
/* 764 */ return cacheUtils.saveSite(options, result, function(err) {
/* 765 */ log.verbose("Site", clean(result));
/* 766 */ return cb(err, result);
});
}
;
/* 769 */ return cb(err, result);
});
};
/* 757 */ site.doSiteConfigGet = function(options, callback) {
/* 758 */ var progress = cli.progress("Retrieving site config information");
/* 759 */ try {
/* 760 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("config").GET(function(err, result) {
/* 770 */ if (err) {
/* 771 */ logError("Failed to get site config info", err);
}
/* 772 */ else {
/* 773 */ log.verbose("SiteConfig", clean(result));
}
;
/* 775 */ callback(err, result);
});
/* 778 */ } finally {
/* 779 */ progress.end();
/* 773 */ site.doSiteConfigGet = function(options, callback) {
/* 774 */ var progress = cli.progress("Retrieving site config information");
/* 775 */ var cb = function(err, result) {
/* 776 */ progress.end();
/* 777 */ return (callback && callback(err, result));
};
/* 779 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("config").GET(function(err, result) {
/* 789 */ if (err) {
/* 790 */ logError("Failed to get site config info", err);
}
/* 791 */ else {
/* 792 */ log.verbose("SiteConfig", clean(result));
}
;
/* 794 */ return cb(err, result);
});
};
/* 783 */ site.doRepositoryGet = function(options, callback) {
/* 784 */ var progress = cli.progress("Retrieving site repository information");
/* 785 */ try {
/* 786 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").GET(function(err, result) {
/* 796 */ if (result) {
/* 797 */ log.verbose("Repository", clean(result));
}
;
/* 799 */ callback(err, clean(result));
});
/* 802 */ } finally {
/* 803 */ progress.end();
/* 798 */ site.doRepositoryGet = function(options, callback) {
/* 799 */ var progress = cli.progress("Retrieving site repository information");
/* 800 */ var cb = function(err, result) {
/* 801 */ progress.end();
/* 802 */ return (callback && callback(err, result));
};
/* 804 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").GET(function(err, result) {
/* 814 */ if (result) {
/* 815 */ log.verbose("Repository", clean(result));
}
;
/* 817 */ return cb(err, clean(result));
});
};
/* 807 */ site.doPublishingUsersGet = function site_doPublishingUsersGet__15(options, _) {
/* 821 */ site.doPublishingUsersGet = function site_doPublishingUsersGet__15(options, _) {
var progress, publishingUsers;
var __frame = {
name: "site_doPublishingUsersGet__15",
line: 807
line: 821
};
return __func(_, this, arguments, site_doPublishingUsersGet__15, 1, __frame, function __$site_doPublishingUsersGet__15() {
/* 808 */ progress = cli.progress("Retrieving user information");
/* 822 */ progress = cli.progress("Retrieving user information");
return (function ___(__then) {
(function ___(_) {
__tryCatch(_, function __$site_doPublishingUsersGet__15() {
/* 816 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").query("properties", "publishingUsers").GET(__cb(_, __frame, 9, 34, function ___(__0, __1) {
/* 810 */ publishingUsers = clean(__1);
/* 818 */ log.verbose("PublishingUsers", publishingUsers);
/* 819 */ return _(null, publishingUsers);
/* 830 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").query("properties", "publishingUsers").GET(__cb(_, __frame, 9, 34, function ___(__0, __1) {
/* 824 */ publishingUsers = clean(__1);
/* 832 */ log.verbose("PublishingUsers", publishingUsers);
/* 833 */ return _(null, publishingUsers);
}, true));
});
})(function ___(__e, __r, __cont) {
(function ___(__then) {
__tryCatch(_, function __$site_doPublishingUsersGet__15() {
/* 822 */ progress.end();
/* 836 */ progress.end();
__then();
});
})(function ___() {
@ -1139,88 +1159,89 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
});
});
};
/* 830 */ var writers = {
/* 831 */ Site: {
/* 832 */ xml: function(site) {
/* 833 */ return function(req) {
/* 834 */ req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
/* 835 */ req.write("<HostNames>");
/* 836 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 837 */ req.write((site.name + cli.category("account").hostNameSuffix()));
/* 838 */ req.write("</string>");
/* 840 */ if (site.hostname) {
/* 841 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 842 */ req.write(site.hostname);
/* 843 */ req.write("</string>");
/* 844 */ var writers = {
/* 845 */ Site: {
/* 846 */ xml: function(site) {
/* 847 */ return function(req) {
/* 848 */ req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
/* 849 */ req.write("<HostNames>");
/* 850 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 851 */ req.write((site.name + cli.category("account").hostNameSuffix()));
/* 852 */ req.write("</string>");
/* 854 */ if (site.hostname) {
/* 855 */ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
/* 856 */ req.write(site.hostname);
/* 857 */ req.write("</string>");
}
;
/* 845 */ req.write("</HostNames>");
/* 846 */ req.write("<Name>");
/* 847 */ req.write(site.name);
/* 848 */ req.write("</Name>");
/* 849 */ req.write("</Site>");
/* 851 */ req.end();
/* 859 */ req.write("</HostNames>");
/* 860 */ req.write("<Name>");
/* 861 */ req.write(site.name);
/* 862 */ req.write("</Name>");
/* 863 */ req.write("</Site>");
/* 865 */ req.end();
};
}
}
};
/* 857 */ function clean(source) {
/* 858 */ if ((typeof (source) === "string")) {
/* 859 */ return source;
/* 871 */ function clean(source) {
/* 872 */ if ((typeof (source) === "string")) {
/* 873 */ return source;
}
;
/* 862 */ var target = {
/* 876 */ var target = {
};
/* 863 */ var hasString = false;
/* 864 */ var hasNonString = false;
/* 865 */ var stringValue = "";
/* 867 */ for (var prop in source) {
/* 868 */ if ((prop == "@")) {
/* 869 */ continue;
/* 877 */ var hasString = false;
/* 878 */ var hasNonString = false;
/* 879 */ var stringValue = "";
/* 881 */ for (var prop in source) {
/* 882 */ if ((prop == "@")) {
/* 883 */ continue;
}
/* 870 */ else {
/* 871 */ if ((((prop === "#") || (prop === "string")) || (prop.substring((prop.length - 7)) === ":string"))) {
/* 872 */ hasString = true;
/* 873 */ stringValue = source[prop];
/* 884 */ else {
/* 885 */ if ((((prop === "#") || (prop === "string")) || (prop.substring((prop.length - 7)) === ":string"))) {
/* 886 */ hasString = true;
/* 887 */ stringValue = source[prop];
}
/* 874 */ else {
/* 875 */ hasNonString = true;
/* 888 */ else {
/* 889 */ hasNonString = true;
}
;
/* 877 */ target[prop] = clean(source[prop]);
/* 891 */ target[prop] = clean(source[prop]);
}
;
};
/* 880 */ if ((hasString && !hasNonString)) {
/* 881 */ return stringValue;
/* 894 */ if ((hasString && !hasNonString)) {
/* 895 */ return stringValue;
}
;
/* 883 */ return target;
/* 897 */ return target;
};
/* 886 */ function logEachData(title, data) {
/* 887 */ var cleaned = clean(data);
/* 888 */ for (var property in cleaned) {
/* 889 */ log.data(((title + " ") + property), cleaned[property]);
/* 900 */ function logEachData(title, data) {
/* 901 */ var cleaned = clean(data);
/* 902 */ for (var property in cleaned) {
/* 903 */ log.data(((title + " ") + property), cleaned[property]);
};
};
/* 893 */ function logError(message, err) {
/* 894 */ if ((arguments.length == 1)) {
/* 895 */ err = message;
/* 896 */ message = undefined;
/* 906 */ site.logEachData = logEachData;
/* 908 */ function logError(message, err) {
/* 909 */ if ((arguments.length == 1)) {
/* 910 */ err = message;
/* 911 */ message = undefined;
}
/* 897 */ else {
/* 898 */ log.error(message);
/* 912 */ else {
/* 913 */ log.error(message);
}
;
/* 901 */ if (err) {
/* 902 */ if (err.message) {
/* 904 */ log.verbose("stack", err.stack);
/* 905 */ log.json("silly", err);
/* 916 */ if (err) {
/* 917 */ if (err.message) {
/* 919 */ log.verbose("stack", err.stack);
/* 920 */ log.json("silly", err);
}
/* 907 */ else if (err.Message) {
/* 909 */ log.json("verbose", clean(err));
/* 922 */ else if (err.Message) {
/* 924 */ log.json("verbose", clean(err));
}
/* 911 */ else {
/* 926 */ else {
}
@ -1228,20 +1249,20 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=
}
;
};
/* 917 */ function isArray(testObject) {
/* 918 */ return (((testObject && !(testObject.propertyIsEnumerable("length"))) && (typeof testObject === "object")) && (typeof testObject.length === "number"));
/* 932 */ function isArray(testObject) {
/* 933 */ return (((testObject && !(testObject.propertyIsEnumerable("length"))) && (typeof testObject === "object")) && (typeof testObject.length === "number"));
};
/* 921 */ function toArray(testObject) {
/* 922 */ return (isArray(testObject) ? testObject : ((typeof testObject === "undefined") ? [] : [testObject,]));
/* 936 */ function toArray(testObject) {
/* 937 */ return (isArray(testObject) ? testObject : ((typeof testObject === "undefined") ? [] : [testObject,]));
};
/* 925 */ function endsWith(str, suffix) {
/* 926 */ return (str.indexOf(suffix, (str.length - suffix.length)) !== -1);
/* 940 */ function endsWith(str, suffix) {
/* 941 */ return (str.indexOf(suffix, (str.length - suffix.length)) !== -1);
};
/* 929 */ function exec(cmd, cb) {
/* 930 */ child_process.exec(cmd, function(err, stdout, stderr) {
/* 931 */ cb(err, {
/* 932 */ stdout: stdout,
/* 933 */ stderr: stderr
/* 944 */ function exec(cmd, cb) {
/* 945 */ child_process.exec(cmd, function(err, stdout, stderr) {
/* 946 */ cb(err, {
/* 947 */ stdout: stdout,
/* 948 */ stderr: stderr
});
});
};

Просмотреть файл

@ -93,7 +93,7 @@ exports.init = function (cli) {
function confirm(label, callback) {
cli.confirm(label, function (x) { callback(undefined, x); });
}
site.confirm = confirm;
site.command('create [name]')
.whiteListPowershell()
@ -364,15 +364,8 @@ exports.init = function (cli) {
logEachData('Site', result[0]);
logEachData('Config', result[1]);
var repositoryUri = null;
for (var i = 0; i < result[0].SiteProperties.Properties.NameValuePair.length; ++i) {
var pair = result[0].SiteProperties.Properties.NameValuePair[i];
if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) {
repositoryUri = !pair.Value['@'] && pair.Value;
break;
}
}
log.data('Repository', repositoryUri ? (clean(repositoryUri) + '/' + context.site.name + '.git') : '');
var repositoryUri = getRepositoryUri(result[0]);
log.data('Repository', repositoryUri ? (repositoryUri + '/' + context.site.name + '.git') : '');
});
function lookupSiteName(context, _) {
@ -382,7 +375,7 @@ exports.init = function (cli) {
}
var cfg = site.readConfig(_);
if (cfg !== undefined && cfg.name) {
if (cfg && cfg.name) {
// using the name from current location
context.site.name = cfg.name;
context.site.webspace = cfg.webspace;
@ -419,6 +412,31 @@ exports.init = function (cli) {
}
lookupSiteWebSpace(context, _);
}
site.lookupSiteNameAndWebSpace = lookupSiteNameAndWebSpace;
function getRepositoryUri(siteData) {
for (var i = 0; i < siteData.SiteProperties.Properties.NameValuePair.length; ++i) {
var pair = siteData.SiteProperties.Properties.NameValuePair[i];
if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) {
return (typeof pair.Value === 'string') ? pair.Value : null;
}
}
}
site.getRepositoryUri = getRepositoryUri;
function getRepositoryAuth(siteData) {
var userName, password;
for (var i = 0; i < siteData.SiteProperties.Properties.NameValuePair.length; ++i) {
var pair = siteData.SiteProperties.Properties.NameValuePair[i];
if (utils.ignoreCaseEquals(pair.Name, "PublishingUsername")) {
userName = pair.Value;
} else if (utils.ignoreCaseEquals(pair.Name, "PublishingPassword")) {
password = pair.Value;
}
}
return userName && (userName + ":" + password);
}
site.getRepositoryAuth = getRepositoryAuth;
site.command('delete [name]')
.whiteListPowershell()
@ -599,32 +617,32 @@ exports.init = function (cli) {
log.verbose('Site', options.site.name);
var progress = cli.progress('Sending site information');
try {
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.header('Content-Type', 'application/xml')
.POST(
writers.Site.xml(options.site),
function (err, result) {
if (err) {
logError('Failed to create site', err);
} else {
return cacheUtils.saveSite(options, result, function (err) {
log.info('Created website at ', clean(result).HostNames);
log.verbose('Site', clean(result));
callback(err, result);
});
}
callback(err, result);
});
}
finally {
var cb = function (err, result) {
progress.end();
}
return callback && callback(err, result);
};
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.header('Content-Type', 'application/xml')
.POST(
writers.Site.xml(options.site),
function (err, result) {
if (err) {
logError('Failed to create site', err);
} else {
return cacheUtils.saveSite(options, result, function (err) {
log.info('Created website at ', clean(result).HostNames);
log.verbose('Site', clean(result));
return cb(err, result);
});
}
return cb(err, result);
});
};
site.doRepositoryPost = function (options, callback) {
@ -634,29 +652,28 @@ exports.init = function (cli) {
log.verbose('Site', options.site.name);
var progress = cli.progress('Updating site information');
try {
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.path('repository')
.POST(
"",
function (err, result) {
if (err) {
logError('Failed to initialize repository', err);
} else {
log.info('Repository initialized');
}
callback(err, result);
});
}
finally {
var cb = function (err, result) {
progress.end();
}
return callback && callback(err, result);
};
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.path('repository')
.POST(
"",
function (err, result) {
if (err) {
logError('Failed to initialize repository', err);
} else {
log.info('Repository initialized');
}
return cb(err, result);
});
};
site.doSpacesGet = function (options, _) {
@ -722,86 +739,83 @@ exports.init = function (cli) {
site.doSiteGet = function (options, callback) {
var progress = cli.progress('Retrieving site information');
try {
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.query('propertiesToInclude', 'repositoryuri,publishingpassword,publishingusername')
.GET(
function (err, result) {
if (err) {
logError('Failed to get site info', err);
if (err.Code === 'NotFound') {
return cacheUtils.deleteSite(options, function () {
callback(err, result);
});
}
} else {
return cacheUtils.saveSite(options, result, function (err) {
log.verbose('Site', clean(result));
callback(err, result);
var cb = function (err, result) {
progress.end();
return callback && callback(err, result);
};
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.query('propertiesToInclude', 'repositoryuri,publishingpassword,publishingusername')
.GET(
function (err, result) {
if (err) {
logError('Failed to get site info', err);
if (err.Code === 'NotFound') {
return cacheUtils.deleteSite(options, function () {
return cb(err, result);
});
}
callback(err, result);
});
}
finally {
progress.end();
}
} else {
return cacheUtils.saveSite(options, result, function (err) {
log.verbose('Site', clean(result));
return cb(err, result);
});
}
return cb(err, result);
});
};
site.doSiteConfigGet = function (options, callback) {
var progress = cli.progress('Retrieving site config information');
try {
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.path('config')
.GET(
function (err, result) {
if (err) {
logError('Failed to get site config info', err);
} else {
log.verbose('SiteConfig', clean(result));
}
callback(err, result);
});
}
finally {
var cb = function (err, result) {
progress.end();
}
return callback && callback(err, result);
};
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.path('config')
.GET(
function (err, result) {
if (err) {
logError('Failed to get site config info', err);
} else {
log.verbose('SiteConfig', clean(result));
}
return cb(err, result);
});
};
site.doRepositoryGet = function (options, callback) {
var progress = cli.progress('Retrieving site repository information');
try {
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.path('repository')
.GET(
function (err, result) {
if (result) {
log.verbose('Repository', clean(result));
}
callback(err, clean(result));
});
}
finally {
var cb = function (err, result) {
progress.end();
}
return callback && callback(err, result);
};
getChannel()
.path(options.subscription)
.path('services')
.path('webspaces')
.path(options.site.webspace)
.path('sites')
.path(options.site.name)
.path('repository')
.GET(
function (err, result) {
if (result) {
log.verbose('Repository', clean(result));
}
return cb(err, clean(result));
});
};
site.doPublishingUsersGet = function (options, _) {
@ -889,6 +903,7 @@ exports.init = function (cli) {
log.data(title + ' ' + property, cleaned[property]);
}
}
site.logEachData = logEachData;
function logError(message, err) {
if (arguments.length == 1) {
@ -935,4 +950,3 @@ exports.init = function (cli) {
});
}
};

Просмотреть файл

@ -227,6 +227,18 @@
<Content Include="..\..\lib\cli\commands\site_.js">
<Link>lib\cli\commands\site_.js</Link>
</Content>
<Content Include="..\..\lib\cli\commands\deployment.js">
<Link>lib\cli\commands\deployment.js</Link>
</Content>
<Content Include="..\..\lib\cli\commands\deployment_.js">
<Link>lib\cli\commands\deployment_.js</Link>
</Content>
<Content Include="..\..\lib\cli\commands\log.js">
<Link>lib\cli\commands\log.js</Link>
</Content>
<Content Include="..\..\lib\cli\commands\log_.js">
<Link>lib\cli\commands\log_.js</Link>
</Content>
<Content Include="..\..\lib\cli\commands\vm.js">
<Link>lib\cli\commands\vm.js</Link>
</Content>