-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: re-add deployExistingRevision to the commands (#245)
- Loading branch information
1 parent
50660b3
commit 8c075a9
Showing
8 changed files
with
507 additions
and
62 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 |
---|---|---|
@@ -1,74 +1,84 @@ | ||
/* jshint node: true */ | ||
'use strict'; | ||
"use strict"; | ||
|
||
const util = require('util'), | ||
defaults = require('../defaults'), | ||
options = require('../options'); | ||
const util = require("util"), | ||
defaults = require("../defaults"), | ||
options = require("../options"); | ||
|
||
var descriptor = defaults.defaultDescriptor({ | ||
'email': { | ||
name: 'Developer Email', | ||
const descriptor = defaults.defaultDescriptor({ | ||
email: { | ||
name: "Developer Email", | ||
required: true | ||
}, | ||
"name": { | ||
name: "App Name", | ||
required: true | ||
name: { | ||
name: "App Name", | ||
required: true | ||
} | ||
}); | ||
|
||
module.exports.descriptor = descriptor; | ||
|
||
module.exports.run = function(opts, cb) { | ||
module.exports.run = function (opts, cb) { | ||
options.validateSync(opts, descriptor); | ||
if (opts.debug) { | ||
console.log('deleteApp: %j', opts); | ||
console.log("deleteApp: %j", opts); | ||
} | ||
var request = defaults.defaultRequest(opts); | ||
deleteApp(opts, request, function(err, results) { | ||
if (err) { | ||
cb(err); | ||
} else { | ||
if (opts.debug) { | ||
console.log('results: %j', results); | ||
} | ||
cb(undefined, results); | ||
const request = defaults.defaultRequest(opts); | ||
deleteApp(opts, request, function (err, results) { | ||
if (err) { | ||
cb(err); | ||
} else { | ||
if (opts.debug) { | ||
console.log("results: %j", results); | ||
} | ||
}); | ||
cb(undefined, results); | ||
} | ||
}); | ||
}; | ||
|
||
function deleteApp(opts,request,done) { | ||
let uri = util.format('%s/v1/o/%s/developers/%s/apps/%s', | ||
opts.baseuri, opts.organization, opts.email, opts.name); | ||
request({ | ||
uri: uri, | ||
method:'DELETE', | ||
json:true | ||
},function(err,res,body){ | ||
var jsonBody = body; | ||
if(err){ | ||
if (opts.debug) { | ||
console.log('Error occured %s', err); | ||
} | ||
done(err); | ||
}else if (res.statusCode === 200) { | ||
if (opts.verbose) { | ||
console.log('Delete successful'); | ||
} | ||
if (opts.debug) { | ||
console.log('%s', body); | ||
} | ||
done(undefined, jsonBody); | ||
}else { | ||
if (opts.verbose) { | ||
console.error('Delete App result: %j', body); | ||
} | ||
var errMsg; | ||
if (jsonBody && (jsonBody.message)) { | ||
errMsg = jsonBody.message; | ||
function deleteApp(opts, request, done) { | ||
let uri = util.format( | ||
"%s/v1/o/%s/developers/%s/apps/%s", | ||
opts.baseuri, | ||
opts.organization, | ||
opts.email, | ||
opts.name | ||
); | ||
|
||
request( | ||
{ | ||
uri, | ||
method: "DELETE", | ||
json: true | ||
}, | ||
function (err, res, jsonBody) { | ||
if (err) { | ||
if (opts.debug) { | ||
console.log("Error occured %s", err); | ||
} | ||
done(err); | ||
} else if (res.statusCode === 200) { | ||
if (opts.verbose) { | ||
console.log("Delete successful"); | ||
} | ||
if (opts.debug) { | ||
console.log("%s", jsonBody); | ||
} | ||
done(undefined, jsonBody); | ||
} else { | ||
errMsg = util.format('Delete App failed with status code %d', res.statusCode); | ||
if (opts.verbose) { | ||
console.error("Delete App result: %j", jsonBody); | ||
} | ||
const errMsg = | ||
jsonBody && jsonBody.message | ||
? jsonBody.message | ||
: util.format( | ||
"Delete App failed with status code %d", | ||
res.statusCode | ||
); | ||
|
||
done(new Error(errMsg)); | ||
} | ||
done(new Error(errMsg)); | ||
} | ||
}); | ||
); | ||
} |
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,53 @@ | ||
const util = require("util"), | ||
defaults = require("../defaults"), | ||
options = require("../options"); | ||
|
||
const descriptor = defaults.defaultDescriptor({ | ||
app: { | ||
name: "app", | ||
shortOption: "a", | ||
required: true, | ||
prompt: true | ||
} | ||
}); | ||
|
||
module.exports.descriptor = descriptor; | ||
|
||
module.exports.format = function (r) { | ||
return r.join("\n"); | ||
}; | ||
|
||
module.exports.run = function (opts, cb) { | ||
options.validateSync(opts, descriptor); | ||
if (opts.debug) { | ||
console.log("listApps: %j", opts); | ||
} | ||
|
||
let uri = util.format( | ||
"%s/v1/o/%s/apps/%s", | ||
opts.baseuri, | ||
opts.organization, | ||
opts.app | ||
); | ||
let request = defaults.defaultRequest(opts); | ||
if (opts.debug) { | ||
console.log('Going to invoke "%s"', uri); | ||
} | ||
request.get(uri, function (err, req, body) { | ||
if (err) { | ||
cb(err); | ||
} else { | ||
if (req.statusCode === 200) { | ||
if (opts.debug) { | ||
console.log("App: %j", body); | ||
} | ||
if (opts.debug) { | ||
console.log("All done"); | ||
} | ||
cb(undefined, body); | ||
} else { | ||
cb(new Error(util.format("HTTP error %d", req.statusCode))); | ||
} | ||
} | ||
}); | ||
}; |
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,41 @@ | ||
const util = require("util"), | ||
defaults = require("../defaults"), | ||
options = require("../options"); | ||
|
||
const descriptor = defaults.defaultDescriptor({}); | ||
|
||
module.exports.descriptor = descriptor; | ||
|
||
module.exports.format = function (r) { | ||
return r.join("\n"); | ||
}; | ||
|
||
module.exports.run = function (opts, cb) { | ||
options.validateSync(opts, descriptor); | ||
if (opts.debug) { | ||
console.log("listApps: %j", opts); | ||
} | ||
|
||
let uri = util.format("%s/v1/o/%s/apps", opts.baseuri, opts.organization); | ||
let request = defaults.defaultRequest(opts); | ||
if (opts.debug) { | ||
console.log('Going to invoke "%s"', uri); | ||
} | ||
request.get(uri, function (err, req, body) { | ||
if (err) { | ||
cb(err); | ||
} else { | ||
if (req.statusCode === 200) { | ||
if (opts.debug) { | ||
console.log("List of Apps: %j", body); | ||
} | ||
if (opts.debug) { | ||
console.log("All done"); | ||
} | ||
cb(undefined, body); | ||
} else { | ||
cb(new Error(util.format("HTTP error %d", req.statusCode))); | ||
} | ||
} | ||
}); | ||
}; |
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,45 @@ | ||
const util = require("util"), | ||
defaults = require("../defaults"), | ||
options = require("../options"); | ||
|
||
const descriptor = defaults.defaultDescriptor({}); | ||
|
||
module.exports.descriptor = descriptor; | ||
|
||
module.exports.format = function (r) { | ||
return r.join("\n"); | ||
}; | ||
|
||
module.exports.run = function (opts, cb) { | ||
options.validateSync(opts, descriptor); | ||
if (opts.debug) { | ||
console.log("listProducts: %j", opts); | ||
} | ||
|
||
let uri = util.format( | ||
"%s/v1/o/%s/apiproducts", | ||
opts.baseuri, | ||
opts.organization | ||
); | ||
let request = defaults.defaultRequest(opts); | ||
if (opts.debug) { | ||
console.log('Going to invoke "%s"', uri); | ||
} | ||
request.get(uri, function (err, req, body) { | ||
if (err) { | ||
cb(err); | ||
} else { | ||
if (req.statusCode === 200) { | ||
if (opts.debug) { | ||
console.log("List of Products: %j", body); | ||
} | ||
if (opts.debug) { | ||
console.log("All done"); | ||
} | ||
cb(undefined, body); | ||
} else { | ||
cb(new Error(util.format("HTTP error %d", req.statusCode))); | ||
} | ||
} | ||
}); | ||
}; |
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
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
Oops, something went wrong.