Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
7529098a50 | |||
15c331690b | |||
29d176bafa | |||
8763926288 | |||
da16094e36 | |||
5fd2b07266 | |||
6618463e0a | |||
93af3cd0e1 | |||
854598ab25 | |||
dffc390637 | |||
ae5b6b5afd | |||
c7f87eebae | |||
63c54ff790 | |||
7670698e84 | |||
7e2481d511 | |||
9ae3acb3d8 | |||
4e12b7ee3b | |||
e07f5717c8 | |||
e0daf85e34 | |||
db27753aac | |||
5d00afcdf0 | |||
011ac2d7b4 | |||
ecede34127 | |||
08fe9e8727 | |||
80806fdca9 | |||
01499cc63a | |||
c8c9d8a407 | |||
527d1b7aa5 | |||
d35fac2278 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,12 +1,11 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
test/temp/
|
||||
test/temp2/
|
||||
coverage/
|
||||
docs/
|
||||
public/
|
||||
pages/
|
||||
|
||||
#npm devug
|
||||
#npm debug
|
||||
npm-debug.log
|
||||
|
||||
ts/*.js
|
||||
|
76
README.md
76
README.md
@ -1,16 +1,68 @@
|
||||
# smartgit is an easy wrapper for nodegit
|
||||
an easy wrapper for nodegit
|
||||
# smartgit
|
||||
smart git wrapper for node.
|
||||
|
||||
### Buildstatus/Dependencies
|
||||
[](https://travis-ci.org/pushrocks/smartgit)
|
||||
[](https://david-dm.org/pushrocks/smartgit#info=devDependencies)
|
||||
[](https://coveralls.io/github/pushrocks/smartgit?branch=master)
|
||||
smartgit expects git to be installed on target machine.
|
||||
|
||||
### Usage
|
||||
This npm package comes with everything you need to start your own gulp plugin.
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartgit)
|
||||
[](https://gitlab.com/pushrocks/smartgit)
|
||||
[](https://github.com/pushrocks/smartgit)
|
||||
[](https://pushrocks.gitlab.io/smartgit/)
|
||||
|
||||
Features:
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||
[](https://david-dm.org/pushrocks/smartgit)
|
||||
[](https://www.bithound.io/github/pushrocks/smartgit/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartgit)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
* easily clone a git repo
|
||||
* easily create a new git repo
|
||||
* easily add all changes and make a new commit
|
||||
## Usage
|
||||
We recommend the use of TypeScript for best in class intellisense
|
||||
|
||||
```javascript
|
||||
// import smartgit:
|
||||
import { GitRepo } from 'smartgit'
|
||||
|
||||
// Initialize smartgit:
|
||||
// -- note: there are 3 ways to initialize smartgit
|
||||
// -- -- 1. with a existing Git repo
|
||||
// -- -- 2. with a cloned Git repo
|
||||
// -- -- 3. with a new Git repo
|
||||
|
||||
// -- 1. existing Git Repo:
|
||||
let myExistingGitRepo = new GitRepo('/path/to/existing/git/repo/')
|
||||
|
||||
// -- 2. cloned Git Repo:
|
||||
let myClonedGitRepo: GitRepo
|
||||
smartgit.createRepoFromClone('git@github.com:username/reponame.git')
|
||||
.then(gitRepo => { // non blocking
|
||||
myClonedGitRepo = gitRepo
|
||||
})
|
||||
|
||||
// -- 3. new Git Repo
|
||||
let myNewGitRepo: GitRepo
|
||||
smartgit.createRepoFromInit('/path/to/new/folder') // smartgit will create any new folder, be careful
|
||||
.then(gitRepo => { // non blocking
|
||||
myNewGitRepo = gitRepo
|
||||
})
|
||||
|
||||
// Using smartgit instance
|
||||
// -- most used actions
|
||||
// -- all actions return promises, so make sure to use promise chaining for any dependent tasks
|
||||
myExistingGitRepo.addAll() // returns promise, stages all changed files
|
||||
myExistingGitRepo.add(['relative/path/to/file.txt','another/file2.txt']) // returns promise, stages specific files
|
||||
myExistingGitRepo.commit('my commit message') // returns promise, commits staged files
|
||||
myExistingGitRepo.status() // returns promise
|
||||
.then(status => { // Use TypeScript for status type information
|
||||
|
||||
})
|
||||
myExistingGitRepo.check() // returns promise, checks repo health
|
||||
myExistingGitRepo.remoteAdd('git@github.com:username/reponame.git')
|
||||
```
|
||||
|
||||
Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment
|
||||
|
||||
[](https://push.rocks)
|
||||
|
14
dist/index.d.ts
vendored
14
dist/index.d.ts
vendored
@ -1,2 +1,12 @@
|
||||
import "typings-global";
|
||||
export { clone } from "./smartgit.clone";
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
import { GitRepo } from './smartgit.classes.gitrepo';
|
||||
export { GitRepo };
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise<GitRepo>;
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export declare let createRepoFromInit: (destinationDirArg: string) => q.Promise<GitRepo>;
|
||||
|
32
dist/index.js
vendored
32
dist/index.js
vendored
@ -1,6 +1,28 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var smartgit_clone_1 = require("./smartgit.clone");
|
||||
exports.clone = smartgit_clone_1.clone;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUVQLENBQUMsQ0FGc0I7QUFJdkIsK0JBQW9CLGtCQUFrQixDQUFDO0FBQS9CLHVDQUErQiIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCJcblxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydGdpdC5wbHVnaW5zXCIpO1xuaW1wb3J0IFNtYXJ0Z2l0Q2hlY2sgPSByZXF1aXJlKFwiLi9zbWFydGdpdC5jaGVja1wiKTtcbmV4cG9ydCB7Y2xvbmV9IGZyb20gXCIuL3NtYXJ0Z2l0LmNsb25lXCI7XG5pbXBvcnQgU21hcnRnaXRDb21taXQgPSByZXF1aXJlKFwiLi9zbWFydGdpdC5jb21taXRcIik7XG5pbXBvcnQgU21hcnRnaXRJbml0ID0gcmVxdWlyZShcIi4vc21hcnRnaXQuaW5pdFwiKTtcblxuXG4iXX0=
|
||||
const q = require("q");
|
||||
const plugins = require("./smartgit.plugins");
|
||||
const smartgit_classes_gitrepo_1 = require("./smartgit.classes.gitrepo");
|
||||
exports.GitRepo = smartgit_classes_gitrepo_1.GitRepo;
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
exports.createRepoFromClone = (fromArg, toArg) => {
|
||||
let done = q.defer();
|
||||
plugins.smartfile.fs.ensureDir(toArg);
|
||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
|
||||
let newRepo = new smartgit_classes_gitrepo_1.GitRepo(toArg);
|
||||
done.resolve(newRepo);
|
||||
return done.promise;
|
||||
};
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
exports.createRepoFromInit = (destinationDirArg) => {
|
||||
let done = q.defer();
|
||||
plugins.smartfile.fs.ensureDir(destinationDirArg);
|
||||
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`);
|
||||
let newRepo = new smartgit_classes_gitrepo_1.GitRepo(destinationDirArg);
|
||||
done.resolve(newRepo);
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDhDQUErQztBQUUvQyx5RUFBb0Q7QUFFaEQscURBQU87QUFHWDs7R0FFRztBQUN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typings-global";
|
||||
export declare let pull: (optionsArg: {
|
||||
path: string;
|
||||
ref?: string;
|
||||
}) => void;
|
10
dist/smartgit.add.js
vendored
10
dist/smartgit.add.js
vendored
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./smartgit.plugins");
|
||||
exports.pull = function (optionsArg) {
|
||||
if (!optionsArg.ref)
|
||||
optionsArg.ref = "master";
|
||||
plugins.nodegit.Repository.open(optionsArg.path);
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmFkZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsWUFBSSxHQUFHLFVBQUMsVUFBb0M7SUFDbkQsRUFBRSxDQUFBLENBQUMsQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDO1FBQUMsVUFBVSxDQUFDLEdBQUcsR0FBRyxRQUFRLENBQUM7SUFDOUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUNyRCxDQUFDLENBQUEiLCJmaWxlIjoic21hcnRnaXQuYWRkLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcbmltcG9ydCAqIGFzIHBsdWdpbnMgZnJvbSBcIi4vc21hcnRnaXQucGx1Z2luc1wiO1xuXG5leHBvcnQgbGV0IHB1bGwgPSAob3B0aW9uc0FyZzp7cGF0aDpzdHJpbmcscmVmPzpzdHJpbmd9KSA9PiB7XG4gICAgaWYoIW9wdGlvbnNBcmcucmVmKSBvcHRpb25zQXJnLnJlZiA9IFwibWFzdGVyXCI7XG4gICAgcGx1Z2lucy5ub2RlZ2l0LlJlcG9zaXRvcnkub3BlbihvcHRpb25zQXJnLnBhdGgpO1xufVxuIl19
|
3
dist/smartgit.check.d.ts
vendored
3
dist/smartgit.check.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import "typings-global";
|
||||
declare var _default: (repoArg: any) => boolean;
|
||||
export = _default;
|
7
dist/smartgit.check.js
vendored
7
dist/smartgit.check.js
vendored
@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
module.exports = function (repoArg) {
|
||||
return true;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNoZWNrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFFdkIsaUJBQVMsVUFBUyxPQUFPO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUM7QUFDaEIsQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0Z2l0LmNoZWNrLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydGdpdC5wbHVnaW5zXCIpO1xuZXhwb3J0ID0gZnVuY3Rpb24ocmVwb0FyZykge1xuICAgIHJldHVybiB0cnVlO1xufTsiXX0=
|
57
dist/smartgit.classes.gitrepo.d.ts
vendored
Normal file
57
dist/smartgit.classes.gitrepo.d.ts
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
/**
|
||||
* class GitRepo allows access to git directories from node
|
||||
*/
|
||||
export declare class GitRepo {
|
||||
repoBase: string;
|
||||
constructor(repoBaseArg: string);
|
||||
/**
|
||||
* checks if the Repo is valid
|
||||
*/
|
||||
check(): boolean;
|
||||
/**
|
||||
* stage all files in working directory
|
||||
*/
|
||||
addAll(dirPathArg: string): q.Promise<{}>;
|
||||
/**
|
||||
* add a remote to the GitRepo
|
||||
*/
|
||||
remoteAdd(remoteNameArg: string, remoteLinkArg: string): q.Promise<{}>;
|
||||
/**
|
||||
* list remotes for a Gip
|
||||
*/
|
||||
remoteList(): q.Promise<{}>;
|
||||
/**
|
||||
* remove remote
|
||||
*/
|
||||
remoteRemove(dirPathArg: string): q.Promise<{}>;
|
||||
/**
|
||||
* commit all files that are currently staged
|
||||
*/
|
||||
commit(commitMessage: string): q.Promise<{}>;
|
||||
/**
|
||||
* pull latest changes from remote
|
||||
*/
|
||||
pull(sourceArg?: string, branchArg?: string): q.Promise<{}>;
|
||||
/**
|
||||
* push new commits to remote
|
||||
*/
|
||||
push(remoteNameArg?: string, remoteBranchArg?: string): q.Promise<{}>;
|
||||
/**
|
||||
* sync
|
||||
*/
|
||||
sync(): void;
|
||||
/**
|
||||
* get the current status
|
||||
*/
|
||||
status(): q.Promise<{}>;
|
||||
}
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise<GitRepo>;
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export declare let createRepoFromInit: (destinationDirArg: string) => void;
|
141
dist/smartgit.classes.gitrepo.js
vendored
Normal file
141
dist/smartgit.classes.gitrepo.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
dist/smartgit.clone.d.ts
vendored
7
dist/smartgit.clone.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import "typings-global";
|
||||
export declare let clone: (optionsArg: {
|
||||
from: string;
|
||||
to: string;
|
||||
keyPath?: string;
|
||||
keyPassphrase?: string;
|
||||
}) => any;
|
42
dist/smartgit.clone.js
vendored
42
dist/smartgit.clone.js
vendored
@ -1,42 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./smartgit.plugins");
|
||||
var SmartgitCheck = require("./smartgit.check");
|
||||
exports.clone = function (optionsArg) {
|
||||
var done = plugins.Q.defer();
|
||||
/***** URL Checks ******/
|
||||
//TODO make smartstring URL test
|
||||
/***** Path Checks ******/
|
||||
if (!/^\/.*/.test(optionsArg.to)) {
|
||||
plugins.beautylog.error("It seems that the given path " + optionsArg.to + " is not absolute.");
|
||||
return;
|
||||
}
|
||||
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 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(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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNsb25lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUMvQyxJQUFPLGFBQWEsV0FBVyxrQkF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b2x2ZSgpO1xuICAgICAgICB9LChlcnIpID0+IHtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKGVycik7XG4gICAgICAgIH0pO1xuICAgIHJldHVybiBkb25lLnByb21pc2U7XG59OyJdfQ==
|
3
dist/smartgit.commit.d.ts
vendored
3
dist/smartgit.commit.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import "typings-global";
|
||||
declare var _default: (pathArg: string, commitMessage: string) => void;
|
||||
export = _default;
|
10
dist/smartgit.commit.js
vendored
10
dist/smartgit.commit.js
vendored
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./smartgit.plugins");
|
||||
module.exports = function (pathArg, commitMessage) {
|
||||
var result = plugins.nodegit.index.addByPath(pathArg);
|
||||
if (result == 0) {
|
||||
}
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNvbW1pdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBQ3ZCLElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFFL0MsaUJBQVMsVUFBUyxPQUFjLEVBQUMsYUFBb0I7SUFDakQsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3RELEVBQUUsQ0FBQyxDQUFDLE1BQU0sSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBRWxCLENBQUM7QUFDTCxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRnaXQuY29tbWl0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydGdpdC5wbHVnaW5zXCIpO1xuXG5leHBvcnQgPSBmdW5jdGlvbihwYXRoQXJnOnN0cmluZyxjb21taXRNZXNzYWdlOnN0cmluZykge1xuICAgIHZhciByZXN1bHQgPSBwbHVnaW5zLm5vZGVnaXQuaW5kZXguYWRkQnlQYXRoKHBhdGhBcmcpO1xuICAgIGlmIChyZXN1bHQgPT0gMCkge1xuICAgICAgICBcbiAgICB9XG59OyJdfQ==
|
3
dist/smartgit.init.d.ts
vendored
3
dist/smartgit.init.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import "typings-global";
|
||||
declare var _default: () => void;
|
||||
export = _default;
|
17
dist/smartgit.init.js
vendored
17
dist/smartgit.init.js
vendored
@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./smartgit.plugins");
|
||||
module.exports = function () {
|
||||
var gitinit = function (dest) {
|
||||
if (dest === void 0) { dest = "undefined"; }
|
||||
if (dest == "undefined") {
|
||||
return; // ...and return function here if not
|
||||
}
|
||||
var isBare = 0; //lets create a subfolder
|
||||
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
|
||||
// do something with repo here.
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmluaXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUN2QixJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBRS9DLGlCQUFTO0lBQ0wsSUFBSSxPQUFPLEdBQUcsVUFBUyxJQUF5QjtRQUF6QixvQkFBeUIsR0FBekIsa0JBQXlCO1FBQzVDLEVBQUUsQ0FBQyxDQUFDLElBQUksSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQ3RCLE1BQU0sQ0FBQyxDQUFDLH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
@ -1 +0,0 @@
|
||||
import "typings-global";
|
4
dist/smartgit.interfaces.js
vendored
4
dist/smartgit.interfaces.js
vendored
@ -1,4 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBRCIsImZpbGUiOiJzbWFydGdpdC5pbnRlcmZhY2VzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIiJdfQ==
|
15
dist/smartgit.plugins.d.ts
vendored
15
dist/smartgit.plugins.d.ts
vendored
@ -1,8 +1,7 @@
|
||||
import "typings-global";
|
||||
export import path = require("path");
|
||||
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");
|
||||
import 'typings-global';
|
||||
export import path = require('path');
|
||||
export import beautylog = require('beautylog');
|
||||
export import shelljs = require('shelljs');
|
||||
export import smartfile = require('smartfile');
|
||||
export import smartpath = require('smartpath');
|
||||
export import smartstring = require('smartstring');
|
||||
|
6
dist/smartgit.plugins.js
vendored
6
dist/smartgit.plugins.js
vendored
@ -2,10 +2,8 @@
|
||||
require("typings-global");
|
||||
exports.path = require("path");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.nodegit = require("nodegit");
|
||||
exports.Q = require("q");
|
||||
exports.shelljs = require("shelljs");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartpath = require("smartpath");
|
||||
exports.smartstring = require("smartstring");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0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OiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHFDQUEwQztBQUMxQyx5Q0FBOEM7QUFDOUMseUNBQThDO0FBQzlDLDZDQUFrRCJ9
|
0
dist/smartgit.pull.d.ts
vendored
0
dist/smartgit.pull.d.ts
vendored
3
dist/smartgit.pull.js
vendored
3
dist/smartgit.pull.js
vendored
@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzbWFydGdpdC5wdWxsLmpzIiwic291cmNlc0NvbnRlbnQiOltdfQ==
|
36
package.json
36
package.json
@ -1,15 +1,17 @@
|
||||
{
|
||||
"name": "smartgit",
|
||||
"version": "0.1.0",
|
||||
"description": "an easy wrapper for nodegit",
|
||||
"version": "1.0.2",
|
||||
"description": "smart git wrapper for node",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"cleanTest": "rm -rf test/temp*",
|
||||
"test": "(npm run cleanTest && npmts)",
|
||||
"install": "node dist/postinstall.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pushrocks/smartgit.git"
|
||||
"url": "https://gitlab.com/pushrocks/smartgit.git"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
@ -19,21 +21,25 @@
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/smartgit/issues"
|
||||
"url": "https://gitlab.com/pushrocks/smartgit/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartgit",
|
||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
||||
"dependencies": {
|
||||
"beautylog": "^5.0.12",
|
||||
"nodegit": "^0.14.1",
|
||||
"@types/minimatch": "*",
|
||||
"@types/shelljs": "^0.3.32",
|
||||
"beautylog": "^6.0.0",
|
||||
"q": "^1.4.1",
|
||||
"smartfile": "^4.0.5",
|
||||
"smartpath": "^3.2.2",
|
||||
"smartstring": "^2.0.10",
|
||||
"typings-global": "^1.0.3"
|
||||
"shelljs": "^0.7.5",
|
||||
"simple-git": "^1.62.0",
|
||||
"smartfile": "^4.1.0",
|
||||
"smartpath": "^3.2.5",
|
||||
"smartstring": "^2.0.22",
|
||||
"typings-global": "^1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts-g": "^5.2.6",
|
||||
"should": "^9.0.2",
|
||||
"typings-test": "^1.0.1"
|
||||
"@types/should": "^8.1.30",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
1
test/temp3
Submodule
1
test/temp3
Submodule
Submodule test/temp3 added at a261a2ea02
3
test/test.d.ts
vendored
3
test/test.d.ts
vendored
@ -1,2 +1 @@
|
||||
import "typings-test";
|
||||
import "should";
|
||||
import 'typings-test';
|
||||
|
121
test/test.js
121
test/test.js
@ -1,35 +1,110 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
var path = require("path");
|
||||
require("should");
|
||||
var smartgit = require("../dist/index");
|
||||
describe("smartgit", function () {
|
||||
describe(".clone", function () {
|
||||
it("should clone a repository using ssh and sshkey", function (done) {
|
||||
this.timeout(10000);
|
||||
smartgit.clone({
|
||||
from: "git@gitlab.com:sandboxzone/sandbox-testrepo.git",
|
||||
to: path.resolve("./test/temp/")
|
||||
}).then(function () {
|
||||
let shelljs = require('shelljs');
|
||||
const path = require("path");
|
||||
const should = require("should");
|
||||
const smartgit = require("../dist/index");
|
||||
let paths = {
|
||||
temp1: path.resolve('./test/temp/'),
|
||||
temp2: path.resolve('./test/temp2/'),
|
||||
temp3: path.resolve('./test/temp3'),
|
||||
temp4: path.resolve('./test/temp4'),
|
||||
noGit: path.resolve('./test/')
|
||||
};
|
||||
describe('smartgit', function () {
|
||||
let testGitRepo;
|
||||
let testGitRepoCloned;
|
||||
let testGitRepoInit;
|
||||
describe('instance', function () {
|
||||
it('should error for invalid path', function (done) {
|
||||
try {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1);
|
||||
}
|
||||
catch (err) {
|
||||
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}
|
||||
});
|
||||
it('should init a new repo', function (done) {
|
||||
this.timeout(40000);
|
||||
smartgit.createRepoFromInit(paths.temp1)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
it("should clone a repository using https", function (done) {
|
||||
this.timeout(10000);
|
||||
smartgit.clone({
|
||||
from: "https://gitlab.com/sandboxzone/sandbox-testrepo.git",
|
||||
to: path.resolve("./test/temp2/")
|
||||
}).then(function () {
|
||||
it('should create am instance for an existing repo', function () {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1);
|
||||
should(testGitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
});
|
||||
it('should clone a repository using ssh and sshkey', function (done) {
|
||||
this.timeout(40000);
|
||||
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp2)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
it('should clone a repository using https', function (done) {
|
||||
this.timeout(40000);
|
||||
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp3)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('.add', function () {
|
||||
it('should add a file to an existing repository', function () {
|
||||
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`);
|
||||
testGitRepo.addAll(paths.temp1);
|
||||
});
|
||||
});
|
||||
describe('.check()', function (done) {
|
||||
it('should check a git repo', function () {
|
||||
let checkResult = testGitRepo.check();
|
||||
should(checkResult).be.true();
|
||||
});
|
||||
});
|
||||
describe('commit', function () {
|
||||
it('should commit a new file to an existing repository', function () {
|
||||
testGitRepo.commit('added a new file');
|
||||
});
|
||||
});
|
||||
describe('pull', function () {
|
||||
this.timeout(40000);
|
||||
it('should pull from origin', function (done) {
|
||||
testGitRepo.pull()
|
||||
.then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".check", function () {
|
||||
describe('push', function () {
|
||||
this.timeout(40000);
|
||||
it('should push to origin', function (done) {
|
||||
testGitRepo.push('origin', 'master')
|
||||
.then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("commit", function () {
|
||||
});
|
||||
describe("init", function () {
|
||||
describe('remote', function () {
|
||||
it('should add a remote', function () {
|
||||
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo');
|
||||
});
|
||||
it('should', function (done) {
|
||||
testGitRepo.remoteList()
|
||||
.then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFFdEIsSUFBTyxJQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDOUIsUUFBTyxRQUVQLENBQUMsQ0FGYztB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HlCQUF5QixFQUFFLFVBQVUsSUFBSTtZQUN4QyxXQUFXLENBQUMsSUFBSSxFQUFFO2lCQUNiLElBQUksQ0FBQztnQkFDRixJQUFJLEVBQUUsQ0FBQTtZQUNWLENBQUMsQ0FBQyxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxNQUFNLEVBQUU7UUFDYixJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO1FBQ25CLEVBQUUsQ0FBQyx1QkFBdUIsRUFBRSxVQUFVLElBQUk7WUFDdEMsV0FBVyxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsUUFBUSxDQUFDO2lCQUMvQixJQUFJLENBQUM7Z0JBQ0YsSUFBSSxFQUFFLENBQUE7WUFDVixDQUFDLENBQUMsQ0FBQTtRQUNWLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7SUFDRixRQUFRLENBQUMsUUFBUSxFQUFFO1FBQ2YsRUFBRSxDQUFDLHFCQUFxQixFQUFFO1lBQ3RCLFdBQVcsQ0FBQyxTQUFTLENBQUMsU0FBUyxFQUFFLHVDQUF1QyxDQUFDLENBQUE7UUFDN0UsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMsUUFBUSxFQUFFLFVBQVMsSUFBSTtZQUN0QixXQUFXLENBQUMsVUFBVSxFQUFFO2lCQUNuQixJQUFJLENBQUM7Z0JBQ0YsSUFBSSxFQUFFLENBQUE7WUFDVixDQUFDLENBQUMsQ0FBQTtRQUNWLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9
|
142
test/test.ts
142
test/test.ts
@ -1,38 +1,112 @@
|
||||
import "typings-test";
|
||||
import beautylog = require("beautylog");
|
||||
import path = require("path");
|
||||
import "should"
|
||||
import 'typings-test'
|
||||
import beautylog = require('beautylog')
|
||||
let shelljs = require('shelljs')
|
||||
import path = require('path')
|
||||
import * as should from 'should'
|
||||
|
||||
import smartgit = require("../dist/index");
|
||||
import smartgit = require('../dist/index')
|
||||
let paths = {
|
||||
temp1: path.resolve('./test/temp/'),
|
||||
temp2: path.resolve('./test/temp2/'),
|
||||
temp3: path.resolve('./test/temp3'),
|
||||
temp4: path.resolve('./test/temp4'),
|
||||
noGit: path.resolve('./test/')
|
||||
}
|
||||
|
||||
describe("smartgit",function(){
|
||||
describe(".clone",function(){
|
||||
it("should clone a repository using ssh and sshkey",function(done){
|
||||
this.timeout(10000);
|
||||
smartgit.clone({
|
||||
from:"git@gitlab.com:sandboxzone/sandbox-testrepo.git",
|
||||
to:path.resolve("./test/temp/")
|
||||
}).then(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should clone a repository using https",function(done){
|
||||
this.timeout(10000);
|
||||
smartgit.clone({
|
||||
from:"https://gitlab.com/sandboxzone/sandbox-testrepo.git",
|
||||
to:path.resolve("./test/temp2/")
|
||||
}).then(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".check",function(){
|
||||
|
||||
});
|
||||
describe("commit",function(){
|
||||
|
||||
});
|
||||
describe("init",function(){
|
||||
|
||||
});
|
||||
});
|
||||
describe('smartgit', function () {
|
||||
let testGitRepo: smartgit.GitRepo
|
||||
let testGitRepoCloned: smartgit.GitRepo
|
||||
let testGitRepoInit: smartgit.GitRepo
|
||||
describe('instance', function () {
|
||||
it('should error for invalid path', function (done) {
|
||||
try {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1)
|
||||
} catch (err) {
|
||||
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}
|
||||
})
|
||||
it('should init a new repo', function (done) {
|
||||
this.timeout(40000)
|
||||
smartgit.createRepoFromInit(paths.temp1)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}).catch(err => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
it('should create am instance for an existing repo', function () {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1)
|
||||
should(testGitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
})
|
||||
it('should clone a repository using ssh and sshkey', function (done) {
|
||||
this.timeout(40000)
|
||||
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp2)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}).catch(err => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
it('should clone a repository using https', function (done) {
|
||||
this.timeout(40000)
|
||||
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp3)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}).catch(err => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('.add', function () {
|
||||
it('should add a file to an existing repository', function () {
|
||||
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`)
|
||||
testGitRepo.addAll(paths.temp1)
|
||||
})
|
||||
})
|
||||
describe('.check()', function(done) {
|
||||
it('should check a git repo', function() {
|
||||
let checkResult = testGitRepo.check()
|
||||
should(checkResult).be.true()
|
||||
})
|
||||
})
|
||||
describe('commit', function () {
|
||||
it('should commit a new file to an existing repository', function () {
|
||||
testGitRepo.commit('added a new file')
|
||||
})
|
||||
})
|
||||
describe('pull', function () {
|
||||
this.timeout(40000)
|
||||
it('should pull from origin', function (done) {
|
||||
testGitRepo.pull()
|
||||
.then(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('push', function () {
|
||||
this.timeout(40000)
|
||||
it('should push to origin', function (done) {
|
||||
testGitRepo.push('origin', 'master')
|
||||
.then(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('remote', function () {
|
||||
it('should add a remote', function () {
|
||||
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo')
|
||||
})
|
||||
it('should', function(done) {
|
||||
testGitRepo.remoteList()
|
||||
.then(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
34
ts/index.ts
34
ts/index.ts
@ -1,9 +1,31 @@
|
||||
import "typings-global"
|
||||
|
||||
import * as q from 'q'
|
||||
import plugins = require("./smartgit.plugins");
|
||||
import SmartgitCheck = require("./smartgit.check");
|
||||
export {clone} from "./smartgit.clone";
|
||||
import SmartgitCommit = require("./smartgit.commit");
|
||||
import SmartgitInit = require("./smartgit.init");
|
||||
|
||||
import { GitRepo } from './smartgit.classes.gitrepo'
|
||||
export {
|
||||
GitRepo
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(toArg)
|
||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`)
|
||||
let newRepo = new GitRepo(toArg)
|
||||
done.resolve(newRepo)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
||||
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`)
|
||||
let newRepo = new GitRepo(destinationDirArg)
|
||||
done.resolve(newRepo)
|
||||
return done.promise
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./smartgit.plugins";
|
||||
|
||||
export let pull = (optionsArg:{path:string,ref?:string}) => {
|
||||
if(!optionsArg.ref) optionsArg.ref = "master";
|
||||
plugins.nodegit.Repository.open(optionsArg.path);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
import "typings-global"
|
||||
import plugins = require("./smartgit.plugins");
|
||||
export = function(repoArg) {
|
||||
return true;
|
||||
};
|
150
ts/smartgit.classes.gitrepo.ts
Normal file
150
ts/smartgit.classes.gitrepo.ts
Normal file
@ -0,0 +1,150 @@
|
||||
import * as q from 'q'
|
||||
import * as plugins from './smartgit.plugins'
|
||||
|
||||
/**
|
||||
* class GitRepo allows access to git directories from node
|
||||
*/
|
||||
export class GitRepo {
|
||||
repoBase: string
|
||||
constructor(repoBaseArg: string) {
|
||||
this.repoBase = repoBaseArg
|
||||
if (!this.check()) {
|
||||
throw new Error('no valid git repo')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the Repo is valid
|
||||
*/
|
||||
check(): boolean {
|
||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
|
||||
}
|
||||
|
||||
/**
|
||||
* stage all files in working directory
|
||||
*/
|
||||
addAll(dirPathArg: string) {
|
||||
let done = q.defer()
|
||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`)
|
||||
done.resolve(dirPathArg)
|
||||
return done.promise
|
||||
};
|
||||
|
||||
/**
|
||||
* add a remote to the GitRepo
|
||||
*/
|
||||
remoteAdd(remoteNameArg: string, remoteLinkArg: string) {
|
||||
let done = q.defer()
|
||||
if (!remoteNameArg) {
|
||||
let err = new Error('smartgit.remote.add expects a valid remote name')
|
||||
plugins.beautylog.error(err.message)
|
||||
done.reject(err)
|
||||
return done.promise
|
||||
};
|
||||
if (!remoteLinkArg) {
|
||||
let err = new Error()
|
||||
plugins.beautylog.error(err.message)
|
||||
done.reject(err)
|
||||
return done.promise
|
||||
};
|
||||
|
||||
// if everything is all right proceed
|
||||
plugins.shelljs.exec(`cd ${this.repoBase} && git remote add ${remoteNameArg} ${remoteLinkArg}`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* list remotes for a Gip
|
||||
*/
|
||||
remoteList() {
|
||||
let done = q.defer()
|
||||
let remotes = {}
|
||||
plugins.shelljs.exec(`cd ${this.repoBase} && git remote -v`)
|
||||
done.resolve(remotes)
|
||||
return done.promise
|
||||
};
|
||||
|
||||
/**
|
||||
* remove remote
|
||||
*/
|
||||
remoteRemove(dirPathArg: string) {
|
||||
let done = q.defer()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* commit all files that are currently staged
|
||||
*/
|
||||
commit(commitMessage: string) {
|
||||
let done = q.defer()
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git commit -m "${commitMessage}")`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pull latest changes from remote
|
||||
*/
|
||||
pull(sourceArg: string = '', branchArg: string = '') {
|
||||
let done = q.defer()
|
||||
// if everything is allright proceed
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git pull ${sourceArg} ${branchArg})`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* push new commits to remote
|
||||
*/
|
||||
push(remoteNameArg: string = '', remoteBranchArg: string = '') {
|
||||
let done = q.defer()
|
||||
// if everything seems allright proceed
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git push ${remoteNameArg} ${remoteBranchArg})`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* sync
|
||||
*/
|
||||
sync() {
|
||||
this.pull().then(() => {
|
||||
this.push()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* get the current status
|
||||
*/
|
||||
status() {
|
||||
let done = q.defer()
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git status)`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(toArg)
|
||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`)
|
||||
let newRepo = new GitRepo(toArg)
|
||||
done.resolve(newRepo)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
||||
plugins.shelljs.exec(`cd destinationDirArg && git init`)
|
||||
let newRepo = new GitRepo(destinationDirArg)
|
||||
done.resolve(newRepo)
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
import "typings-global"
|
||||
import plugins = require("./smartgit.plugins");
|
||||
import SmartgitCheck = require("./smartgit.check");
|
||||
|
||||
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(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 " + optionsArg.from);
|
||||
var cloneOptions:any = {
|
||||
fetchOpts: {
|
||||
callbacks: {
|
||||
certificateCheck: function() { return 1; },
|
||||
credentials: function(url, userName) {
|
||||
let gitRepo = new plugins.smartstring.GitRepo(url);
|
||||
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(optionsArg.from, optionsArg.to, cloneOptions)
|
||||
.then(() => {
|
||||
SmartgitCheck(cloneRepository);
|
||||
done.resolve();
|
||||
},(err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
import "typings-global"
|
||||
import plugins = require("./smartgit.plugins");
|
||||
|
||||
export = function(pathArg:string,commitMessage:string) {
|
||||
var result = plugins.nodegit.index.addByPath(pathArg);
|
||||
if (result == 0) {
|
||||
|
||||
}
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
import "typings-global"
|
||||
import plugins = require("./smartgit.plugins");
|
||||
|
||||
export = function(){
|
||||
var gitinit = function(dest:string = "undefined") {
|
||||
if (dest == "undefined") { //lets check if a destination is defined...
|
||||
return; // ...and return function here if not
|
||||
}
|
||||
var isBare = 0; //lets create a subfolder
|
||||
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
|
||||
// do something with repo here.
|
||||
});
|
||||
};
|
||||
}
|
@ -1 +0,0 @@
|
||||
import "typings-global"
|
@ -1,11 +1,7 @@
|
||||
import "typings-global"
|
||||
|
||||
export import path = require("path");
|
||||
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");
|
||||
|
||||
|
||||
import 'typings-global'
|
||||
export import path = require('path')
|
||||
export import beautylog = require('beautylog')
|
||||
export import shelljs = require('shelljs')
|
||||
export import smartfile = require('smartfile')
|
||||
export import smartpath = require('smartpath')
|
||||
export import smartstring = require('smartstring')
|
||||
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user