now has better sshKey understanding
This commit is contained in:
parent
f0cab00277
commit
14492ff7a8
4
dist/smartgit.clone.d.ts
vendored
4
dist/smartgit.clone.d.ts
vendored
@ -1,5 +1,7 @@
|
||||
import "typings-global";
|
||||
export declare let clone: (options: {
|
||||
export declare let clone: (optionsArg: {
|
||||
from: string;
|
||||
to: string;
|
||||
keyPath?: string;
|
||||
keyPassphrase?: string;
|
||||
}) => any;
|
||||
|
25
dist/smartgit.clone.js
vendored
25
dist/smartgit.clone.js
vendored
@ -2,36 +2,41 @@
|
||||
require("typings-global");
|
||||
var plugins = require("./smartgit.plugins");
|
||||
var SmartgitCheck = require("./smartgit.check");
|
||||
exports.clone = function (options) {
|
||||
exports.clone = function (optionsArg) {
|
||||
var done = plugins.Q.defer();
|
||||
/***** URL Checks ******/
|
||||
//TODO make smartstring URL test
|
||||
/***** Path Checks ******/
|
||||
if (!/^\/.*/.test(options.to)) {
|
||||
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
|
||||
if (!/^\/.*/.test(optionsArg.to)) {
|
||||
plugins.beautylog.error("It seems that the given path " + optionsArg.to + " is not absolute.");
|
||||
return;
|
||||
}
|
||||
plugins.beautylog.log("Now cloning " + options.from);
|
||||
plugins.beautylog.log("Now cloning " + optionsArg.from);
|
||||
var cloneOptions = {
|
||||
fetchOpts: {
|
||||
callbacks: {
|
||||
certificateCheck: function () { return 1; },
|
||||
credentials: function (url, userName) {
|
||||
var gitRepo = new plugins.smartstring.GitRepo(url);
|
||||
var sshDirPath;
|
||||
var pubKey;
|
||||
var privKey;
|
||||
return plugins.nodegit.Cred.sshKeyMemoryNew(userName, pubKey, privKey, "");
|
||||
var host = gitRepo.host;
|
||||
var sshDir = plugins.path.join(plugins.smartpath.get.home(), ".ssh/");
|
||||
var pubKeyPath = plugins.path.join(sshDir, host + ".pub");
|
||||
var privKeyPath = plugins.path.join(sshDir, host);
|
||||
if (!optionsArg.keyPassphrase)
|
||||
optionsArg.keyPassphrase = "";
|
||||
return plugins.nodegit.Cred.sshKeyNew(userName, pubKeyPath, privKeyPath, optionsArg.keyPassphrase);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var cloneRepository = plugins.nodegit.Clone.clone(options.from, options.to, cloneOptions)
|
||||
var cloneRepository = plugins.nodegit.Clone.clone(optionsArg.from, optionsArg.to, cloneOptions)
|
||||
.then(function () {
|
||||
SmartgitCheck(cloneRepository);
|
||||
done.resolve();
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNsb25lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUMvQyxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBRXhDLGFBQUssR0FBRyxVQUFDLE9BQStCO0lBQy9DLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IseUJBQXlCO0lBQ3pCLGdDQUFnQztJQUVoQywwQkFBMEI7SUFDMUIsRUFBRSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDM0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsK0JBQStCLEdBQUcsT0FBTyxDQUFDLEVBQUUsR0FBRyxtQkFBbUIsQ0FBQyxDQUFDO1FBQzVGLE1BQU0sQ0FBQztJQUNYLENBQUM7SUFFRCxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEdBQUcsT0FBTyxDQUFDLElB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AgICAgICAgbGV0IHNzaERpclBhdGg6c3RyaW5nO1xuICAgICAgICAgICAgICAgICAgICBsZXQgcHViS2V5OnN0cmluZztcbiAgICAgICAgICAgICAgICAgICAgbGV0IHByaXZLZXk6c3RyaW5nO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGx1Z2lucy5ub2RlZ2l0LkNyZWQuc3NoS2V5TWVtb3J5TmV3KHVzZXJOYW1lLCBwdWJLZXksIHByaXZLZXksIFwiXCIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgdmFyIGNsb25lUmVwb3NpdG9yeSA9IHBsdWdpbnMubm9kZWdpdC5DbG9uZS5jbG9uZShvcHRpb25zLmZyb20sIG9wdGlvbnMudG8sIGNsb25lT3B0aW9ucylcbiAgICAgICAgLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgU21hcnRnaXRDaGVjayhjbG9uZVJlcG9zaXRvcnkpO1xuICAgICAgICAgICAgZG9uZS5yZXNvbHZlKCk7XG4gICAgICAgIH0pO1xuICAgIHJldHVybiBkb25lLnByb21pc2U7XG59OyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNsb25lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUMvQyxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBRXhDLGFBQUssR0FBRyxVQUFDLFVBS2Y7SUFDRCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLHlCQUF5QjtJQUN6QixnQ0FBZ0M7SUFFaEMsMEJBQTBCO0lBQzFC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gICAgICAgICAgIGxldCBzc2hEaXIgPSBwbHVnaW5zLnBhdGguam9pbihwbHVnaW5zLnNtYXJ0cGF0aC5nZXQuaG9tZSgpLFwiLnNzaC9cIilcbiAgICAgICAgICAgICAgICAgICAgbGV0IHB1YktleVBhdGggPSBwbHVnaW5zLnBhdGguam9pbihzc2hEaXIsaG9zdCArIFwiLnB1YlwiKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHByaXZLZXlQYXRoOnN0cmluZyA9IHBsdWdpbnMucGF0aC5qb2luKHNzaERpcixob3N0KTtcbiAgICAgICAgICAgICAgICAgICAgaWYoIW9wdGlvbnNBcmcua2V5UGFzc3BocmFzZSkgb3B0aW9uc0FyZy5rZXlQYXNzcGhyYXNlID0gXCJcIjtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBsdWdpbnMubm9kZWdpdC5DcmVkLnNzaEtleU5ldyh1c2VyTmFtZSwgcHViS2V5UGF0aCwgcHJpdktleVBhdGgsb3B0aW9uc0FyZy5rZXlQYXNzcGhyYXNlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIHZhciBjbG9uZVJlcG9zaXRvcnkgPSBwbHVnaW5zLm5vZGVnaXQuQ2xvbmUuY2xvbmUob3B0aW9uc0FyZy5mcm9tLCBvcHRpb25zQXJnLnRvLCBjbG9uZU9wdGlvbnMpXG4gICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgIFNtYXJ0Z2l0Q2hlY2soY2xvbmVSZXBvc2l0b3J5KTtcbiAgICAgICAgICAgIGRvbmUucmVzb2x2ZSgpO1xuICAgICAgICB9LChlcnIpID0+IHtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKGVycik7XG4gICAgICAgIH0pO1xuICAgIHJldHVybiBkb25lLnByb21pc2U7XG59OyJdfQ==
|
||||
|
1
dist/smartgit.plugins.d.ts
vendored
1
dist/smartgit.plugins.d.ts
vendored
@ -4,4 +4,5 @@ export import beautylog = require("beautylog");
|
||||
export declare let nodegit: any;
|
||||
export declare let Q: any;
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartpath = require("smartpath");
|
||||
export import smartstring = require("smartstring");
|
||||
|
3
dist/smartgit.plugins.js
vendored
3
dist/smartgit.plugins.js
vendored
@ -5,6 +5,7 @@ exports.beautylog = require("beautylog");
|
||||
exports.nodegit = require("nodegit");
|
||||
exports.Q = require("q");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartpath = require("smartpath");
|
||||
exports.smartstring = require("smartstring");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBRVAsQ0FBQyxDQUZzQjtBQUVULFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ3BDLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDN0IsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNkLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydGdpdC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxuXG5leHBvcnQgaW1wb3J0IHBhdGggPSByZXF1aXJlKFwicGF0aFwiKTtcbmV4cG9ydCBpbXBvcnQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgbm9kZWdpdCA9IHJlcXVpcmUoXCJub2RlZ2l0XCIpO1xuZXhwb3J0IGxldCBRID0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ZVwiKTtcbmV4cG9ydCBpbXBvcnQgc21hcnRwYXRoID0gcmVxdWlyZShcInNtYXJ0cGF0aFwiKTtcbmV4cG9ydCBpbXBvcnQgc21hcnRzdHJpbmcgPSByZXF1aXJlKFwic21hcnRzdHJpbmdcIik7XG5cblxuIl19
|
||||
|
@ -27,6 +27,7 @@
|
||||
"nodegit": "^0.14.1",
|
||||
"q": "^1.4.1",
|
||||
"smartfile": "^4.0.5",
|
||||
"smartpath": "^3.2.2",
|
||||
"smartstring": "^2.0.10",
|
||||
"typings-global": "^1.0.3"
|
||||
},
|
||||
|
@ -2,36 +2,45 @@ import "typings-global"
|
||||
import plugins = require("./smartgit.plugins");
|
||||
import SmartgitCheck = require("./smartgit.check");
|
||||
|
||||
export let clone = (options:{from:string,to:string}) => {
|
||||
export let clone = (optionsArg:{
|
||||
from:string,
|
||||
to:string,
|
||||
keyPath?:string,
|
||||
keyPassphrase?:string
|
||||
}) => {
|
||||
let done = plugins.Q.defer();
|
||||
/***** URL Checks ******/
|
||||
//TODO make smartstring URL test
|
||||
|
||||
/***** Path Checks ******/
|
||||
if (!/^\/.*/.test(options.to)){ //check wether path is absolute
|
||||
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
|
||||
if (!/^\/.*/.test(optionsArg.to)){ //check wether path is absolute
|
||||
plugins.beautylog.error("It seems that the given path " + optionsArg.to + " is not absolute.");
|
||||
return;
|
||||
}
|
||||
|
||||
plugins.beautylog.log("Now cloning " + options.from);
|
||||
plugins.beautylog.log("Now cloning " + optionsArg.from);
|
||||
var cloneOptions:any = {
|
||||
fetchOpts: {
|
||||
callbacks: {
|
||||
certificateCheck: function() { return 1; },
|
||||
credentials: function(url, userName) {
|
||||
let gitRepo = new plugins.smartstring.GitRepo(url);
|
||||
let sshDirPath:string;
|
||||
let pubKey:string;
|
||||
let privKey:string;
|
||||
return plugins.nodegit.Cred.sshKeyMemoryNew(userName, pubKey, privKey, "");
|
||||
let host = gitRepo.host;
|
||||
let sshDir = plugins.path.join(plugins.smartpath.get.home(),".ssh/")
|
||||
let pubKeyPath = plugins.path.join(sshDir,host + ".pub");
|
||||
let privKeyPath:string = plugins.path.join(sshDir,host);
|
||||
if(!optionsArg.keyPassphrase) optionsArg.keyPassphrase = "";
|
||||
return plugins.nodegit.Cred.sshKeyNew(userName, pubKeyPath, privKeyPath,optionsArg.keyPassphrase);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var cloneRepository = plugins.nodegit.Clone.clone(options.from, options.to, cloneOptions)
|
||||
var cloneRepository = plugins.nodegit.Clone.clone(optionsArg.from, optionsArg.to, cloneOptions)
|
||||
.then(() => {
|
||||
SmartgitCheck(cloneRepository);
|
||||
done.resolve();
|
||||
},(err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
@ -5,6 +5,7 @@ export import beautylog = require("beautylog");
|
||||
export let nodegit = require("nodegit");
|
||||
export let Q = require("q");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartpath = require("smartpath");
|
||||
export import smartstring = require("smartstring");
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user