Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
776d5b2f23 | |||
f9a3cd4149 | |||
14492ff7a8 | |||
f0cab00277 | |||
6331887373 | |||
98d28a14c5 | |||
76eb47f245 | |||
2b9fa4e8b7 | |||
28845ec1fd | |||
6b8621588d | |||
ae0536d909 | |||
1dbfdeea3c | |||
7e75a788ab | |||
3073fc1f3c | |||
760b5557f3 | |||
1aae44a0ec | |||
53a5a3a805 |
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,11 +1,11 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
test/temp/
|
||||
test/temp2/
|
||||
coverage/
|
||||
docs/
|
||||
public/
|
||||
pages/
|
||||
|
||||
#npm devug
|
||||
#npm debug
|
||||
npm-debug.log
|
||||
|
||||
ts/*.js
|
||||
|
49
.gitlab-ci.yml
Normal file
49
.gitlab-ci.yml
Normal file
@ -0,0 +1,49 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
|
||||
before_script:
|
||||
- npmci prepare ssh
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
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 cone 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)
|
||||
|
12
dist/index.d.ts
vendored
Normal file
12
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/// <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) => void;
|
39
dist/index.js
vendored
39
dist/index.js
vendored
@ -1,14 +1,27 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
"use strict";
|
||||
var SmartgitCheck = require("./smartgit.check");
|
||||
var SmartgitClone = require("./smartgit.clone");
|
||||
var SmartgitCommit = require("./smartgit.commit");
|
||||
var SmartgitInit = require("./smartgit.init");
|
||||
var smartgit = {};
|
||||
smartgit.clone = SmartgitClone;
|
||||
smartgit.commit = SmartgitCommit;
|
||||
smartgit.check = SmartgitCheck;
|
||||
smartgit.init = SmartgitInit;
|
||||
module.exports = smartgit;
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFHNUMsSUFBTyxhQUFhLFdBQVcsa0JBQWtCLENBQUMsQ0FBQztBQUNuRCxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBQ25ELElBQU8sY0FBYyxXQUFXLG1CQUFtQixDQUFDLENBQUM7QUFDckQsSUFBTyxZQUFZLFdBQVcsaUJBQWlCLENBQUMsQ0FBQztBQUVqRCxJQUFJLFFBQVEsR0FBTyxFQUFFLENBQUM7QUFDdEIsUUFBUSxDQUFDLEtBQUssR0FBRyxhQUFhLENBQUM7QUFDL0IsUUFBUSxDQUFDLE1BQU0sR0FBRyxjQUFjLENBQUM7QUFDakMsUUFBUSxDQUFDLEtBQUssR0FBRyxhQUFhLENBQUM7QUFDL0IsUUFBUSxDQUFDLElBQUksR0FBRyxZQUFZLENBQUM7QUFHN0IsTUFBTSxDQUFDLE9BQU8sR0FBRyxRQUFRLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRnaXQucGx1Z2luc1wiKTtcbmltcG9ydCBTbWFydGdpdENoZWNrID0gcmVxdWlyZShcIi4vc21hcnRnaXQuY2hlY2tcIik7XG5pbXBvcnQgU21hcnRnaXRDbG9uZSA9IHJlcXVpcmUoXCIuL3NtYXJ0Z2l0LmNsb25lXCIpO1xuaW1wb3J0IFNtYXJ0Z2l0Q29tbWl0ID0gcmVxdWlyZShcIi4vc21hcnRnaXQuY29tbWl0XCIpO1xuaW1wb3J0IFNtYXJ0Z2l0SW5pdCA9IHJlcXVpcmUoXCIuL3NtYXJ0Z2l0LmluaXRcIik7XG5cbnZhciBzbWFydGdpdDphbnkgPSB7fTtcbnNtYXJ0Z2l0LmNsb25lID0gU21hcnRnaXRDbG9uZTtcbnNtYXJ0Z2l0LmNvbW1pdCA9IFNtYXJ0Z2l0Q29tbWl0O1xuc21hcnRnaXQuY2hlY2sgPSBTbWFydGdpdENoZWNrO1xuc21hcnRnaXQuaW5pdCA9IFNtYXJ0Z2l0SW5pdDtcblxuXG5tb2R1bGUuZXhwb3J0cyA9IHNtYXJ0Z2l0O1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
||||
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);
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDhDQUErQztBQUUvQyx5RUFBb0Q7QUFFaEQscURBQU87QUFHWDs7R0FFRztBQUNRLFFBQUEsbUJBQW1CLEdBQUcsQ0FBQyxPQUFlLEVBQUUsS0FBYTtJQUM1RCxJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFXLENBQUE7SUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ3JDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGFBQWEsT0FBTyxJQUFJLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDckQsSUFBSSxPQUFPLEdBQUcsSUFBSSxrQ0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2hDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLGtCQUFrQixHQUFHLENBQUMsaUJBQXlCO0lBQ3RELElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQVcsQ0FBQTtJQUM3QixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUNqRCxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxrQ0FBa0MsQ0FBQyxDQUFBO0lBQ3hELElBQUksT0FBTyxHQUFHLElBQUksa0NBQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQUFBO0lBQzVDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7QUFDekIsQ0FBQyxDQUFBIn0=
|
3
dist/smartgit.add.js
vendored
3
dist/smartgit.add.js
vendored
@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzbWFydGdpdC5hZGQuanMiLCJzb3VyY2VzQ29udGVudCI6W10sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
6
dist/smartgit.check.js
vendored
6
dist/smartgit.check.js
vendored
@ -1,6 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function (repoArg) {
|
||||
return true;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNoZWNrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxpQkFBUyxVQUFTLE9BQU87SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQztBQUNoQixDQUFDLENBQUMiLCJmaWxlIjoic21hcnRnaXQuY2hlY2suanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0Z2l0LnBsdWdpbnNcIik7XG5leHBvcnQgPSBmdW5jdGlvbihyZXBvQXJnKSB7XG4gICAgcmV0dXJuIHRydWU7XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
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(dirPathArg: any): 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;
|
143
dist/smartgit.classes.gitrepo.js
vendored
Normal file
143
dist/smartgit.classes.gitrepo.js
vendored
Normal file
File diff suppressed because one or more lines are too long
25
dist/smartgit.clone.js
vendored
25
dist/smartgit.clone.js
vendored
@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = require("./smartgit.plugins");
|
||||
var SmartgitCheck = require("./smartgit.check");
|
||||
module.exports = function (options) {
|
||||
var done = plugins.Q.defer();
|
||||
/***** URL Checks ******/
|
||||
if (options.from == "undefined" || options.to == "undefined") {
|
||||
plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
|
||||
return;
|
||||
}
|
||||
/***** Path Checks ******/
|
||||
if (!/^\/.*/.test(options.to)) {
|
||||
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
|
||||
return;
|
||||
}
|
||||
plugins.beautylog.log("Now cloning " + options.from);
|
||||
var cloneOptions = {};
|
||||
var cloneRepository = plugins.nodegit.Clone(options.from, options.to, cloneOptions);
|
||||
SmartgitCheck(cloneRepository);
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNsb25lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDNUMsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUMvQyxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBRW5ELGlCQUFTLFVBQVMsT0FBTztJQUNyQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMs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FueSA9IHt9O1xuICAgIHZhciBjbG9uZVJlcG9zaXRvcnkgPSBwbHVnaW5zLm5vZGVnaXQuQ2xvbmUob3B0aW9ucy5mcm9tLCBvcHRpb25zLnRvLCBjbG9uZU9wdGlvbnMpO1xuICAgIFNtYXJ0Z2l0Q2hlY2soY2xvbmVSZXBvc2l0b3J5KTtcbiAgICBkb25lLnJlc29sdmUoKTtcbiAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xufTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
10
dist/smartgit.commit.js
vendored
10
dist/smartgit.commit.js
vendored
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = require("./smartgit.plugins");
|
||||
module.exports = function (pathArg, commitMessage) {
|
||||
var result = plugins.nodegit.index.addByPath(pathArg);
|
||||
if (result == 0) {
|
||||
}
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNvbW1pdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsNENBQTRDO0FBQzVDLElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFFL0MsaUJBQVMsVUFBUyxPQUFjLEVBQUMsYUFBb0I7SUFDakQsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3RELEVBQUUsQ0FBQyxDQUFDLE1BQU0sSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBRWxCLENBQUM7QUFDTCxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRnaXQuY29tbWl0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydGdpdC5wbHVnaW5zXCIpO1xuXG5leHBvcnQgPSBmdW5jdGlvbihwYXRoQXJnOnN0cmluZyxjb21taXRNZXNzYWdlOnN0cmluZykge1xuICAgIHZhciByZXN1bHQgPSBwbHVnaW5zLm5vZGVnaXQuaW5kZXguYWRkQnlQYXRoKHBhdGhBcmcpO1xuICAgIGlmIChyZXN1bHQgPT0gMCkge1xuICAgICAgICBcbiAgICB9XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
17
dist/smartgit.init.js
vendored
17
dist/smartgit.init.js
vendored
@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
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;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmluaXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBRS9DLGlCQUFTO0lBQ0wsSUFBSSxPQUFPLEdBQUcsVUFBUyxJQUF5QjtRQUF6QixvQkFBeUIsR0FBekIsa0JBQXlCO1FBQzVDLEVBQUUsQ0FBQyxDQUFDLElBQUksSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQ3RCLE1BQU0sQ0FBQyxDQUFDLHFDQUFxQztRQUNqRCxDQUFDO1FBQ0QsSUFBSSxNQUFNL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it.interfaces.js
vendored
@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzbWFydGdpdC5pbnRlcmZhY2VzLmpzIiwic291cmNlc0NvbnRlbnQiOltdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
7
dist/smartgit.plugins.d.ts
vendored
Normal file
7
dist/smartgit.plugins.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
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');
|
11
dist/smartgit.plugins.js
vendored
11
dist/smartgit.plugins.js
vendored
@ -1,8 +1,9 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.path = require("path");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.nodegit = require("nodegit");
|
||||
exports.Q = require("q");
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDOztBQUVqQyxZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDN0IsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydGdpdC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5leHBvcnQgbGV0IHBhdGggPSByZXF1aXJlKFwicGF0aFwiKTtcbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgbm9kZWdpdCA9IHJlcXVpcmUoXCJub2RlZ2l0XCIpO1xuZXhwb3J0IGxldCBRID0gcmVxdWlyZShcInFcIik7XG5cblxuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
||||
exports.shelljs = require("shelljs");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartpath = require("smartpath");
|
||||
exports.smartstring = require("smartstring");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHFDQUEwQztBQUMxQyx5Q0FBOEM7QUFDOUMseUNBQThDO0FBQzlDLDZDQUFrRCJ9
|
34
package.json
34
package.json
@ -1,14 +1,17 @@
|
||||
{
|
||||
"name": "smartgit",
|
||||
"version": "0.0.10",
|
||||
"description": "an easy wrapper for nodegit",
|
||||
"version": "1.0.1",
|
||||
"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",
|
||||
@ -18,16 +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": "^3.1.2",
|
||||
"nodegit": "^0.12.1",
|
||||
"q": "^1.4.1"
|
||||
"@types/minimatch": "*",
|
||||
"@types/shelljs": "^0.3.32",
|
||||
"beautylog": "^6.0.0",
|
||||
"q": "^1.4.1",
|
||||
"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": "^4.0.1",
|
||||
"should": "^8.3.0"
|
||||
"@types/should": "^8.1.30",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
1
test/test.d.ts
vendored
Normal file
1
test/test.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import 'typings-test';
|
89
test/test.js
89
test/test.js
@ -1,26 +1,79 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
var smartgit = require("../dist/index.js");
|
||||
var beautylog = require("beautylog");
|
||||
var path = require("path");
|
||||
var should = require("should");
|
||||
describe("smartgit", function () {
|
||||
describe(".clone", function () {
|
||||
it("should clone a repository", function (done) {
|
||||
this.timeout(10000);
|
||||
smartgit.clone({
|
||||
from: "https://github.com/pushrocks/docs.git",
|
||||
to: path.resolve("./test/temp/")
|
||||
}).then(function () {
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
let shelljs = require('shelljs');
|
||||
const path = require("path");
|
||||
const should = require("should");
|
||||
const smartgit = require("../dist/index");
|
||||
let paths = {
|
||||
temp: 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 create a valid new instance from path', function () {
|
||||
testGitRepo = new smartgit.GitRepo('path.temp');
|
||||
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.temp)
|
||||
.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.temp2)
|
||||
.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.temp} && cp ../test.js .)`);
|
||||
testGitRepo.addAll(paths.temp);
|
||||
});
|
||||
});
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzNDLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNyQyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDM0IsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBRS9CLFFBQVEsQ0FBQyxVQUFVLEVBQUM7SUFDaEIsUUFBUSxDQUFDLFFBQVEsRUFBQztRQUNkLEVBQUUsQ0FBQywyQkFBMkIsRUFBQyxVQUFTLElBQUk7WUFDeEMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUNwQixRQUFRLENBQUMsS0FBSyxDQUFDO2dCQUNYLElBQUksRUFBQyx1Q0FBdUM7Z0JBQzVDLEVBQUUsRUFBQyxJQUFJLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQzthQUNsQyxDQUFDLENBQUMsSUFBSSxDQUFDO2dCQUNKLElBQU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0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsRUFBRSxDQUFDLHVCQUF1QixFQUFFLFVBQVUsSUFBSTtZQUN0QyxXQUFXLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRSxRQUFRLENBQUM7aUJBQy9CLElBQUksQ0FBQztnQkFDRixJQUFJLEVBQUUsQ0FBQTtZQUNWLENBQUMsQ0FBQyxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxRQUFRLEVBQUU7UUFDZixFQUFFLENBQUMscUJBQXFCLEVBQUU7WUFDdEIsV0FBVyxDQUFDLFNBQVMsQ0FBQyxTQUFTLEVBQUUsdUNBQXVDLENBQUMsQ0FBQTtRQUM3RSxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
104
test/test.ts
104
test/test.ts
@ -1,28 +1,80 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
let smartgit = require("../dist/index.js");
|
||||
let beautylog = require("beautylog");
|
||||
let path = require("path");
|
||||
let should = require("should");
|
||||
import 'typings-test'
|
||||
import beautylog = require('beautylog')
|
||||
let shelljs = require('shelljs')
|
||||
import path = require('path')
|
||||
import * as should from 'should'
|
||||
|
||||
describe("smartgit",function(){
|
||||
describe(".clone",function(){
|
||||
it("should clone a repository",function(done){
|
||||
this.timeout(10000);
|
||||
smartgit.clone({
|
||||
from:"https://github.com/pushrocks/docs.git",
|
||||
to:path.resolve("./test/temp/")
|
||||
}).then(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".check",function(){
|
||||
import smartgit = require('../dist/index')
|
||||
let paths = {
|
||||
temp: path.resolve('./test/temp/'),
|
||||
temp2: path.resolve('./test/temp2/'),
|
||||
temp3: path.resolve('./test/temp3'),
|
||||
temp4: path.resolve('./test/temp4'),
|
||||
noGit: path.resolve('./test/')
|
||||
}
|
||||
|
||||
});
|
||||
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 create a valid new instance from path', function () {
|
||||
testGitRepo = new smartgit.GitRepo('path.temp')
|
||||
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.temp)
|
||||
.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.temp2)
|
||||
.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.temp} && cp ../test.js .)`)
|
||||
testGitRepo.addAll(paths.temp)
|
||||
})
|
||||
})
|
||||
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')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
38
ts/index.ts
38
ts/index.ts
@ -1,16 +1,30 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
|
||||
import * as q from 'q'
|
||||
import plugins = require("./smartgit.plugins");
|
||||
import SmartgitCheck = require("./smartgit.check");
|
||||
import SmartgitClone = require("./smartgit.clone");
|
||||
import SmartgitCommit = require("./smartgit.commit");
|
||||
import SmartgitInit = require("./smartgit.init");
|
||||
|
||||
var smartgit:any = {};
|
||||
smartgit.clone = SmartgitClone;
|
||||
smartgit.commit = SmartgitCommit;
|
||||
smartgit.check = SmartgitCheck;
|
||||
smartgit.init = SmartgitInit;
|
||||
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
|
||||
}
|
||||
|
||||
module.exports = smartgit;
|
||||
/**
|
||||
* 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,5 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./smartgit.plugins");
|
||||
export = function(repoArg) {
|
||||
return true;
|
||||
};
|
151
ts/smartgit.classes.gitrepo.ts
Normal file
151
ts/smartgit.classes.gitrepo.ts
Normal file
@ -0,0 +1,151 @@
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the Repo is valid
|
||||
*/
|
||||
check(): boolean {
|
||||
try {
|
||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(dirPathArg) {
|
||||
let done = q.defer()
|
||||
let remotes = {}
|
||||
plugins.shelljs.exec(`cd ${dirPathArg} && 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,26 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./smartgit.plugins");
|
||||
import SmartgitCheck = require("./smartgit.check");
|
||||
|
||||
export = function(options){
|
||||
let done = plugins.Q.defer();
|
||||
/***** URL Checks ******/
|
||||
if (options.from == "undefined" || options.to == "undefined") {
|
||||
plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
|
||||
return;
|
||||
}
|
||||
|
||||
/***** 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.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
plugins.beautylog.log("Now cloning " + options.from);
|
||||
var cloneOptions:any = {};
|
||||
var cloneRepository = plugins.nodegit.Clone(options.from, options.to, cloneOptions);
|
||||
SmartgitCheck(cloneRepository);
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
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 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
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,8 +1,7 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
|
||||
export let path = require("path");
|
||||
export let beautylog = require("beautylog");
|
||||
export let nodegit = require("nodegit");
|
||||
export let Q = require("q");
|
||||
|
||||
|
||||
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')
|
||||
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"colors": "registry:dt/colors#0.6.0-1+20160317120654",
|
||||
"mocha": "registry:dt/mocha#2.2.5+20160317120654",
|
||||
"node": "registry:dt/node#4.0.0+20160330064709"
|
||||
}
|
||||
}
|
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