This repository has been archived by the owner on May 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add set branch and delete repo command
- Loading branch information
Showing
4 changed files
with
347 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/*** 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(_, _); }); }); };}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* Copyright (c) Microsoft. All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
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(branch, name, options, _) { | ||
var context = { | ||
subscription: cli.category('account').lookupSubscriptionId(options.subscription), | ||
settingKey: 'branch', | ||
settingValue: branch, | ||
site: { name: name } | ||
}; | ||
|
||
var repositoryUri = scm.ensureRepositoryUri(context, _); | ||
if (repositoryUri) { | ||
doSettingsSet(context, _); | ||
} else { | ||
log.error('Repository is not setup'); | ||
} | ||
}); | ||
|
||
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(name, options, _) { | ||
var context = { | ||
subscription: cli.category('account').lookupSubscriptionId(options.subscription), | ||
site: { name: name } | ||
}; | ||
|
||
var repositoryUri = scm.ensureRepositoryUri(context, _); | ||
if (repositoryUri) { | ||
if (!options.quiet && !site.confirm('Delete repository? (y/n) ', _)) { | ||
return; | ||
} | ||
|
||
doDeleteRepository(context, _); | ||
site.doRepositoryDelete(context, _); | ||
} else { | ||
log.error('Repository is not setup'); | ||
} | ||
}); | ||
|
||
function doSettingsGet(context, _) { | ||
var channel = scm.getScmChannel(context) | ||
.path('settings'); | ||
if (context.settingKey !== undefined) { | ||
channel.path(context.settingKey); | ||
} | ||
|
||
var progress = cli.progress('Retrieving repository ' + (context.settingKey ? (context.settingKey + ' ') : '') + 'settings'); | ||
try { | ||
return channel.GET(_); | ||
} finally { | ||
progress.end(); | ||
} | ||
}; | ||
repository.doSettingsGet = doSettingsGet; | ||
|
||
function doSettingsSet(context, _) { | ||
var channel = scm.getScmChannel(context) | ||
.path('settings'); | ||
var data = { | ||
key: context.settingKey, | ||
value: context.settingValue | ||
}; | ||
|
||
var progress = cli.progress('Setting ' + context.settingKey + ' to ' + context.settingValue); | ||
try { | ||
return channel.header('content-type', 'application/json').POST(JSON.stringify(data), _); | ||
} finally { | ||
progress.end(); | ||
} | ||
}; | ||
|
||
function doDeleteRepository(context, _) { | ||
var channel = scm.getScmChannel(context) | ||
.path('live/scm'); | ||
|
||
var progress = cli.progress('Cleaning up repository files'); | ||
try { | ||
return channel.DELETE(_); | ||
} finally { | ||
progress.end(); | ||
} | ||
}; | ||
}; |
Oops, something went wrong.