Compare commits
58 Commits
Author | SHA1 | Date | |
---|---|---|---|
958a625633 | |||
871fd55c5c | |||
07fd9b9fa7 | |||
62d6a8d685 | |||
047cf02e6a | |||
69127cacdd | |||
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 | |||
776d5b2f23 | |||
f9a3cd4149 | |||
14492ff7a8 | |||
f0cab00277 | |||
6331887373 | |||
98d28a14c5 | |||
76eb47f245 | |||
2b9fa4e8b7 | |||
28845ec1fd | |||
6b8621588d | |||
ae0536d909 | |||
1dbfdeea3c | |||
7e75a788ab | |||
3073fc1f3c | |||
760b5557f3 | |||
1aae44a0ec | |||
53a5a3a805 | |||
c4958baf52 | |||
57f185080c | |||
adce81b084 | |||
bf77c64b78 | |||
072f4960f5 | |||
00f34eb67f |
10
.gitignore
vendored
10
.gitignore
vendored
@ -1,13 +1,13 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
|
||||||
.idea/
|
|
||||||
test/temp/
|
test/temp/
|
||||||
|
test/temp2/
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
#npm devug
|
#npm debug
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
ts/typings/
|
ts/typings/
|
||||||
|
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
|
@ -2,6 +2,10 @@ language: node_js
|
|||||||
node_js:
|
node_js:
|
||||||
- 4
|
- 4
|
||||||
- stable
|
- stable
|
||||||
|
before_install:
|
||||||
|
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||||
|
- sudo apt-get update
|
||||||
|
- sudo apt-get install libstdc++-4.9-dev -y
|
||||||
deploy:
|
deploy:
|
||||||
provider: npm
|
provider: npm
|
||||||
email: npm@lossless.digital
|
email: npm@lossless.digital
|
||||||
|
75
README.md
75
README.md
@ -1,15 +1,68 @@
|
|||||||
# smartgit is an easy wrapper for nodegit
|
# smartgit
|
||||||
an easy wrapper for nodegit
|
smart git wrapper for node.
|
||||||
|
|
||||||
### Buildstatus/Dependencies
|
smartgit expects git to be installed on target machine.
|
||||||
[](https://travis-ci.org/pushrocks/smartgit)
|
|
||||||
[](https://david-dm.org/pushrocks/smartgit#info=devDependencies)
|
|
||||||
|
|
||||||
### Usage
|
## Availabililty
|
||||||
This npm package comes with everything you need to start your own gulp plugin.
|
[](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
|
## Usage
|
||||||
* easily create a new git repo
|
We recommend the use of TypeScript for best in class intellisense
|
||||||
* easily add all changes and make a new commit
|
|
||||||
|
```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) => q.Promise<GitRepo>;
|
40
dist/index.js
vendored
40
dist/index.js
vendored
@ -1,14 +1,28 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
"use strict";
|
"use strict";
|
||||||
var SmartgitCheck = require("./smartgit.check");
|
const q = require("q");
|
||||||
var SmartgitClone = require("./smartgit.clone");
|
const plugins = require("./smartgit.plugins");
|
||||||
var SmartgitCommit = require("./smartgit.commit");
|
const smartgit_classes_gitrepo_1 = require("./smartgit.classes.gitrepo");
|
||||||
var SmartgitInit = require("./smartgit.init");
|
exports.GitRepo = smartgit_classes_gitrepo_1.GitRepo;
|
||||||
var smartgit = {};
|
/**
|
||||||
smartgit.clone = SmartgitClone;
|
* creates a new GitRepo Instance after cloning a project
|
||||||
smartgit.commit = SmartgitCommit;
|
*/
|
||||||
smartgit.check = SmartgitCheck;
|
exports.createRepoFromClone = (fromArg, toArg) => {
|
||||||
smartgit.init = SmartgitInit;
|
let done = q.defer();
|
||||||
module.exports = smartgit;
|
plugins.smartfile.fs.ensureDir(toArg);
|
||||||
|
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFHNUMsSUFBTyxhQUFhLFdBQVcsa0JBQWtCLENBQUMsQ0FBQztBQUNuRCxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBQ25ELElBQU8sY0FBYyxXQUFXLG1CQUFtQixDQUFDLENBQUM7QUFDckQsSUFBTyxZQUFZLFdBQVcsaUJBQWlCLENBQUMsQ0FBQztBQUVqRCxJQUFJLFFBQVEsR0FBTyxFQUFFLENBQUM7QUFDdEIsUUFBUSxDQUFDLEtBQUssR0FBRyxhQUFhLENBQUM7QUFDL0IsUUFBUSxDQUFDLE1BQU0sR0FBRyxjQUFjLENBQUM7QUFDakMsUUFBUSxDQUFDLEtBQUssR0FBRyxhQUFhLENBQUM7QUFDL0IsUUFBUSxDQUFDLElBQUksR0FBRyxZQUFZLENBQUM7QUFHN0IsTUFBTSxDQUFDLE9BQU8sR0FBRyxRQUFRLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRnaXQucGx1Z2luc1wiKTtcbmltcG9ydCBTbWFydGdpdENoZWNrID0gcmVxdWlyZShcIi4vc21hcnRnaXQuY2hlY2tcIik7XG5pbXBvcnQgU21hcnRnaXRDbG9uZSA9IHJlcXVpcmUoXCIuL3NtYXJ0Z2l0LmNsb25lXCIpO1xuaW1wb3J0IFNtYXJ0Z2l0Q29tbWl0ID0gcmVxdWlyZShcIi4vc21hcnRnaXQuY29tbWl0XCIpO1xuaW1wb3J0IFNtYXJ0Z2l0SW5pdCA9IHJlcXVpcmUoXCIuL3NtYXJ0Z2l0LmluaXRcIik7XG5cbnZhciBzbWFydGdpdDphbnkgPSB7fTtcbnNtYXJ0Z2l0LmNsb25lID0gU21hcnRnaXRDbG9uZTtcbnNtYXJ0Z2l0LmNvbW1pdCA9IFNtYXJ0Z2l0Q29tbWl0O1xuc21hcnRnaXQuY2hlY2sgPSBTbWFydGdpdENoZWNrO1xuc21hcnRnaXQuaW5pdCA9IFNtYXJ0Z2l0SW5pdDtcblxuXG5tb2R1bGUuZXhwb3J0cyA9IHNtYXJ0Z2l0O1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDhDQUErQztBQUUvQyx5RUFBb0Q7QUFFaEQscURBQU87QUFHWDs7R0FFRztBQUNRLFFBQUEsbUJBQW1CLEdBQUcsQ0FBQyxPQUFlLEVBQUUsS0FBYTtJQUM1RCxJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFXLENBQUE7SUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ3JDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGFBQWEsT0FBTyxJQUFJLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDckQsSUFBSSxPQUFPLEdBQUcsSUFBSSxrQ0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2hDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLGtCQUFrQixHQUFHLENBQUMsaUJBQXlCO0lBQ3RELElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQVcsQ0FBQTtJQUM3QixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUNqRCxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLGlCQUFpQixjQUFjLENBQUMsQ0FBQTtJQUMzRCxJQUFJLE9BQU8sR0FBRyxJQUFJLGtDQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUM1QyxJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9
|
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==
|
|
58
dist/smartgit.classes.gitrepo.d.ts
vendored
Normal file
58
dist/smartgit.classes.gitrepo.d.ts
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/// <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
|
||||||
|
* @executes SYNC
|
||||||
|
*/
|
||||||
|
addAll(): 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;
|
142
dist/smartgit.classes.gitrepo.js
vendored
Normal file
142
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNsb25lLnRzIl0sIm5hbWV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ZSBnaXZlbiBwYXRoIFwiICsgb3B0aW9ucy50byArIFwiIGlzIG5vdCBhYnNvbHV0ZS5cIik7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG5cblxuICAgIHBsdWdpbnMuYmVhdXR5bG9nLmxvZyhcIk5vdyBjbG9uaW5nIFwiICsgb3B0aW9ucy5mcm9tKTtcbiAgICB2YXIgY2xvbmVPcHRpb25zOmFueSA9IHt9O1xuICAgIHZhciBjbG9uZVJlcG9zaXRvcnkgPSBwbHVnaW5zLm5vZGVnaXQuQ2xvbmUob3B0aW9ucy5mcm9tLCBvcHRpb25zLnRvLCBjbG9uZU9wdGlvbnMpO1xuICAgIFNtYXJ0Z2l0Q2hlY2soY2xvbmVSZXBvc2l0b3J5KTtcbiAgICBkb25lLnJlc29sdmUoKTtcbiAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xufTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmluaXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLD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JhcmUgPSAwOyAvL2xldHMgY3JlYXRlIGEgc3ViZm9sZGVyXG4gICAgICAgIHBsdWdpbnMubm9kZWdpdC5SZXBvc2l0b3J5LmluaXQoZGVzdCwgaXNCYXJlKS50aGVuKGZ1bmN0aW9uIChyZXBvKSB7XG4gICAgICAgICAgICAvLyBkbyBzb21ldGhpbmcgd2l0aCByZXBvIGhlcmUuXG4gICAgICAgIH0pO1xuICAgIH07XG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
|
3
dist/smartgit.interfaces.js
vendored
3
dist/smartgit.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";
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
exports.path = require("path");
|
exports.path = require("path");
|
||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
exports.nodegit = require("nodegit");
|
exports.shelljs = require("shelljs");
|
||||||
exports.Q = require("q");
|
exports.smartfile = require("smartfile");
|
||||||
|
exports.smartpath = require("smartpath");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDOztBQUVqQyxZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDN0IsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydGdpdC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5leHBvcnQgbGV0IHBhdGggPSByZXF1aXJlKFwicGF0aFwiKTtcbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgbm9kZWdpdCA9IHJlcXVpcmUoXCJub2RlZ2l0XCIpO1xuZXhwb3J0IGxldCBRID0gcmVxdWlyZShcInFcIik7XG5cblxuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
exports.smartstring = require("smartstring");
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHFDQUEwQztBQUMxQyx5Q0FBOEM7QUFDOUMseUNBQThDO0FBQzlDLDZDQUFrRCJ9
|
12
npmextra.json
Normal file
12
npmextra.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"npmts": {
|
||||||
|
"mode": "default",
|
||||||
|
"codecov": true,
|
||||||
|
"coverageTreshold": 71
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"globalNpmTools": [
|
||||||
|
"npmts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
33
package.json
33
package.json
@ -1,14 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "smartgit",
|
"name": "smartgit",
|
||||||
"version": "0.0.8",
|
"version": "1.0.5",
|
||||||
"description": "an easy wrapper for nodegit",
|
"description": "smart git wrapper for node",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"cleanTest": "rm -rf test/temp*",
|
||||||
|
"test": "(npm run cleanTest && npmts)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pushrocks/smartgit.git"
|
"url": "https://gitlab.com/pushrocks/smartgit.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"json",
|
"json",
|
||||||
@ -18,16 +20,25 @@
|
|||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"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": {
|
"dependencies": {
|
||||||
"beautylog": "3.1.2",
|
"@types/minimatch": "*",
|
||||||
"nodegit": "0.12.1",
|
"@types/shelljs": "^0.3.32",
|
||||||
"q": "1.4.1"
|
"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": {
|
"devDependencies": {
|
||||||
"npmts": "3.6.10",
|
"@types/should": "^8.1.30",
|
||||||
"should": "^8.3.0"
|
"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
1
test/test.d.ts
vendored
Normal file
1
test/test.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import 'typings-test';
|
122
test/test.js
122
test/test.js
@ -1,26 +1,110 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
"use strict";
|
||||||
var smartgit = require("../dist/index.js");
|
require("typings-test");
|
||||||
var beautylog = require("beautylog");
|
let shelljs = require('shelljs');
|
||||||
var path = require("path");
|
const path = require("path");
|
||||||
var should = require("should");
|
const should = require("should");
|
||||||
describe("smartgit", function () {
|
const smartgit = require("../dist/index");
|
||||||
describe(".clone", function () {
|
let paths = {
|
||||||
it("should clone a repository", function (done) {
|
temp1: path.resolve('./test/temp/'),
|
||||||
this.timeout(10000);
|
temp2: path.resolve('./test/temp2/'),
|
||||||
smartgit.clone({
|
temp3: path.resolve('./test/temp3'),
|
||||||
from: "https://github.com/pushrocks/docs.git",
|
temp4: path.resolve('./test/temp4'),
|
||||||
to: path.resolve("./test/temp/")
|
noGit: path.resolve('./test/')
|
||||||
}).then(function () {
|
};
|
||||||
|
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 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('.check()', function () {
|
||||||
|
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();
|
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('remote', function () {
|
||||||
});
|
it('should add a remote', function () {
|
||||||
describe("init", function () {
|
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo');
|
||||||
|
});
|
||||||
|
it('should', function (done) {
|
||||||
|
testGitRepo.remoteList()
|
||||||
|
.then(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQixJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBU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IH0pO1xuICAgICAgICB9KTtcbiAgICB9KTtcbiAgICBkZXNjcmliZShcIi5jaGVja1wiLGZ1bmN0aW9uKCl7XG5cbiAgICB9KTtcbiAgICBkZXNjcmliZShcImNvbW1pdFwiLGZ1bmN0aW9uKCl7XG5cbiAgICB9KTtcbiAgICBkZXNjcmliZShcImluaXRcIixmdW5jdGlvbigpe1xuXG4gICAgfSk7XG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
|
132
test/test.ts
132
test/test.ts
@ -1,28 +1,112 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
import 'typings-test'
|
||||||
let smartgit = require("../dist/index.js");
|
import beautylog = require('beautylog')
|
||||||
let beautylog = require("beautylog");
|
let shelljs = require('shelljs')
|
||||||
let path = require("path");
|
import path = require('path')
|
||||||
let should = require("should");
|
import * as should from 'should'
|
||||||
|
|
||||||
describe("smartgit",function(){
|
import smartgit = require('../dist/index')
|
||||||
describe(".clone",function(){
|
let paths = {
|
||||||
it("should clone a repository",function(done){
|
temp1: path.resolve('./test/temp/'),
|
||||||
this.timeout(10000);
|
temp2: path.resolve('./test/temp2/'),
|
||||||
smartgit.clone({
|
temp3: path.resolve('./test/temp3'),
|
||||||
from:"https://github.com/pushrocks/docs.git",
|
temp4: path.resolve('./test/temp4'),
|
||||||
to:path.resolve("./test/temp/")
|
noGit: path.resolve('./test/')
|
||||||
}).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()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('.check()', function() {
|
||||||
|
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()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
39
ts/index.ts
39
ts/index.ts
@ -1,16 +1,31 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import * as q from 'q'
|
||||||
|
|
||||||
import plugins = require("./smartgit.plugins");
|
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 = {};
|
import { GitRepo } from './smartgit.classes.gitrepo'
|
||||||
smartgit.clone = SmartgitClone;
|
export {
|
||||||
smartgit.commit = SmartgitCommit;
|
GitRepo
|
||||||
smartgit.check = SmartgitCheck;
|
}
|
||||||
smartgit.init = SmartgitInit;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
return done.promise
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
|
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
|
||||||
|
* @executes SYNC
|
||||||
|
*/
|
||||||
|
addAll() {
|
||||||
|
let done = q.defer()
|
||||||
|
plugins.shelljs.exec(`(cd ${this.repoBase} && git add -A && git status)`)
|
||||||
|
done.resolve(this.repoBase)
|
||||||
|
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,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" />
|
import 'typings-global'
|
||||||
|
export import path = require('path')
|
||||||
export let path = require("path");
|
export import beautylog = require('beautylog')
|
||||||
export let beautylog = require("beautylog");
|
export import shelljs = require('shelljs')
|
||||||
export let nodegit = require("nodegit");
|
export import smartfile = require('smartfile')
|
||||||
export let Q = require("q");
|
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