Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
958a625633 | |||
871fd55c5c | |||
07fd9b9fa7 | |||
62d6a8d685 | |||
047cf02e6a | |||
69127cacdd | |||
7529098a50 | |||
15c331690b | |||
29d176bafa | |||
8763926288 | |||
da16094e36 | |||
5fd2b07266 | |||
6618463e0a | |||
93af3cd0e1 | |||
854598ab25 | |||
dffc390637 | |||
ae5b6b5afd |
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,12 +1,11 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
|
||||||
.idea/
|
|
||||||
test/temp/
|
test/temp/
|
||||||
test/temp2/
|
test/temp2/
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
#npm devug
|
#npm debug
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
ts/*.js
|
ts/*.js
|
||||||
|
79
README.md
79
README.md
@ -1,23 +1,68 @@
|
|||||||
# smartgit is an easy wrapper for nodegit
|
# smartgit
|
||||||
a wrapper for git. This plugin does not use nodegit as nodegit appears to have too many bugs for now.
|
smart git wrapper for node.
|
||||||
|
|
||||||
### Buildstatus/Dependencies
|
smartgit expects git to be installed on target machine.
|
||||||
|
|
||||||
|
## Availabililty
|
||||||
|
[](https://www.npmjs.com/package/smartgit)
|
||||||
|
[](https://gitlab.com/pushrocks/smartgit)
|
||||||
|
[](https://github.com/pushrocks/smartgit)
|
||||||
|
[](https://pushrocks.gitlab.io/smartgit/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||||
[](https://david-dm.org/pushrocks/smartgit#info=devDependencies)
|
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||||
[](https://coveralls.io/github/pushrocks/smartgit?branch=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/)
|
||||||
|
|
||||||
### Usage
|
## Usage
|
||||||
This plugin exposes some easified method wrappers for nodegit.
|
We recommend the use of TypeScript for best in class intellisense
|
||||||
This limits options but reduces errors (TypeScript) and speeds up usage.
|
|
||||||
|
|
||||||
Features:
|
```javascript
|
||||||
|
// import smartgit:
|
||||||
|
import { GitRepo } from 'smartgit'
|
||||||
|
|
||||||
* clone a git repo
|
// Initialize smartgit:
|
||||||
* init a new repo
|
// -- note: there are 3 ways to initialize smartgit
|
||||||
* create a new git repo
|
// -- -- 1. with a existing Git repo
|
||||||
* add changes and make a new commit
|
// -- -- 2. with a cloned Git repo
|
||||||
* commit changes
|
// -- -- 3. with a new Git repo
|
||||||
* push changes
|
|
||||||
* add/remove remotes
|
|
||||||
|
|
||||||
Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment
|
// -- 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)
|
||||||
|
20
dist/index.d.ts
vendored
20
dist/index.d.ts
vendored
@ -1,8 +1,12 @@
|
|||||||
export { add } from "./smartgit.add";
|
/// <reference types="q" />
|
||||||
export { clone } from "./smartgit.clone";
|
import * as q from 'q';
|
||||||
export { commit } from "./smartgit.commit";
|
import { GitRepo } from './smartgit.classes.gitrepo';
|
||||||
export { init } from "./smartgit.init";
|
export { GitRepo };
|
||||||
export { pull } from "./smartgit.pull";
|
/**
|
||||||
export { push } from "./smartgit.push";
|
* creates a new GitRepo Instance after cloning a project
|
||||||
export { remote } from "./smartgit.remote";
|
*/
|
||||||
export { status } from "./smartgit.status";
|
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>;
|
||||||
|
44
dist/index.js
vendored
44
dist/index.js
vendored
@ -1,18 +1,28 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var smartgit_add_1 = require("./smartgit.add");
|
const q = require("q");
|
||||||
exports.add = smartgit_add_1.add;
|
const plugins = require("./smartgit.plugins");
|
||||||
var smartgit_clone_1 = require("./smartgit.clone");
|
const smartgit_classes_gitrepo_1 = require("./smartgit.classes.gitrepo");
|
||||||
exports.clone = smartgit_clone_1.clone;
|
exports.GitRepo = smartgit_classes_gitrepo_1.GitRepo;
|
||||||
var smartgit_commit_1 = require("./smartgit.commit");
|
/**
|
||||||
exports.commit = smartgit_commit_1.commit;
|
* creates a new GitRepo Instance after cloning a project
|
||||||
var smartgit_init_1 = require("./smartgit.init");
|
*/
|
||||||
exports.init = smartgit_init_1.init;
|
exports.createRepoFromClone = (fromArg, toArg) => {
|
||||||
var smartgit_pull_1 = require("./smartgit.pull");
|
let done = q.defer();
|
||||||
exports.pull = smartgit_pull_1.pull;
|
plugins.smartfile.fs.ensureDir(toArg);
|
||||||
var smartgit_push_1 = require("./smartgit.push");
|
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
|
||||||
exports.push = smartgit_push_1.push;
|
let newRepo = new smartgit_classes_gitrepo_1.GitRepo(toArg);
|
||||||
var smartgit_remote_1 = require("./smartgit.remote");
|
done.resolve(newRepo);
|
||||||
exports.remote = smartgit_remote_1.remote;
|
return done.promise;
|
||||||
var smartgit_status_1 = require("./smartgit.status");
|
};
|
||||||
exports.status = smartgit_status_1.status;
|
/**
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsNkJBQWtCLGdCQUFnQixDQUFDO0FBQTNCLGlDQUEyQjtBQUNuQywrQkFBb0Isa0JBQWtCLENBQUM7QUFBL0IsdUNBQStCO0FBQ3ZDLGdDQUFxQixtQkFBbUIsQ0FBQztBQUFqQywwQ0FBaUM7QUFDekMsOEJBQW1CLGlCQUFpQixDQUFDO0FBQTdCLG9DQUE2QjtBQUNyQyw4QkFBbUIsaUJBQWlCLENBQUM7QUFBN0Isb0NBQTZCO0FBQ3JDLDhCQUFtQixpQkFBaUIsQ0FBQztBQUE3QixvQ0FBNkI7QUFDckMsZ0NBQXFCLG1CQUFtQixDQUFDO0FBQWpDLDBDQUFpQztBQUN6QyxnQ0FBcUIsbUJBQW1CLENBQUM7QUFBakMsMENBQWlDIn0=
|
* 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
|
0
dist/postinstall.d.ts
vendored
0
dist/postinstall.d.ts
vendored
3
dist/postinstall.js
vendored
3
dist/postinstall.js
vendored
@ -1,3 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var shelljs = require("shelljs");
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9zdGluc3RhbGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wb3N0aW5zdGFsbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDIn0=
|
|
3
dist/smartgit.add.d.ts
vendored
3
dist/smartgit.add.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
export declare let add: {
|
|
||||||
addAll: (dirPathArg: string) => any;
|
|
||||||
};
|
|
20
dist/smartgit.add.js
vendored
20
dist/smartgit.add.js
vendored
@ -1,20 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
var helpers = require("./smartgit.helpers");
|
|
||||||
var addAll = function (dirPathArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.add expects a valid git directory!");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// if everything is ok proceed
|
|
||||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git add -A && git status)");
|
|
||||||
done.resolve(dirPathArg);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
exports.add = {
|
|
||||||
addAll: addAll
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuYWRkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuYWRkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFOUMsSUFBSSxNQUFNLEdBQUcsVUFBQyxVQUFpQjtJQUMzQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQSxDQUFDLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDcEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsNkNBQTZDLENBQUMsQ0FBQztRQUN2RSxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLDhCQUE4QjtJQUM5QixPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsa0NBQStCLENBQUMsQ0FBQztJQUN2RSxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQ3pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQUVTLFdBQUcsR0FBRztJQUNiLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ==
|
|
2
dist/smartgit.check.d.ts
vendored
2
dist/smartgit.check.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
declare var _default: (repoArg: any) => boolean;
|
|
||||||
export = _default;
|
|
5
dist/smartgit.check.js
vendored
5
dist/smartgit.check.js
vendored
@ -1,5 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function (repoArg) {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY2hlY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGdpdC5jaGVjay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsaUJBQVMsVUFBUyxPQUFPO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUM7QUFDaEIsQ0FBQyxDQUFDIn0=
|
|
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
7
dist/smartgit.clone.d.ts
vendored
7
dist/smartgit.clone.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
export declare let clone: (optionsArg: {
|
|
||||||
from: string;
|
|
||||||
to: string;
|
|
||||||
key?: string;
|
|
||||||
keyPath?: string;
|
|
||||||
keyPassphrase?: string;
|
|
||||||
}) => any;
|
|
10
dist/smartgit.clone.js
vendored
10
dist/smartgit.clone.js
vendored
@ -1,10 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
exports.clone = function (optionsArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
plugins.smartfile.fs.ensureDir(optionsArg.to);
|
|
||||||
plugins.shelljs.exec("git clone " + optionsArg.from + " " + optionsArg.to);
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY2xvbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGdpdC5jbG9uZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUdwQyxhQUFLLEdBQUcsVUFBQyxVQU1uQjtJQUNHLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUMsQ0FBQztJQUM5QyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxlQUFhLFVBQVUsQ0FBQyxJQUFJLFNBQUksVUFBVSxDQUFDLEVBQUksQ0FBQyxDQUFDO0lBQ3RFLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9
|
|
1
dist/smartgit.commit.d.ts
vendored
1
dist/smartgit.commit.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let commit: (dirPathArg: string, commitMessage: string) => any;
|
|
17
dist/smartgit.commit.js
vendored
17
dist/smartgit.commit.js
vendored
@ -1,17 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
var helpers = require("./smartgit.helpers");
|
|
||||||
exports.commit = function (dirPathArg, commitMessage) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.commit expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// if everything is all right proceed
|
|
||||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git commit -m \"" + commitMessage + "\")");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY29tbWl0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuY29tbWl0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsY0FBTSxHQUFHLFVBQUMsVUFBaUIsRUFBQyxhQUFvQjtJQUN2RCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQSxDQUFDLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDcEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsK0NBQStDLENBQUMsQ0FBQztRQUN6RSxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLHFDQUFxQztJQUNyQyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsNEJBQXNCLGFBQWEsUUFBSSxDQUFDLENBQUM7SUFDL0UsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDIn0=
|
|
1
dist/smartgit.helpers.d.ts
vendored
1
dist/smartgit.helpers.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let isGitDirectory: (dirPathArg: any) => boolean;
|
|
11
dist/smartgit.helpers.js
vendored
11
dist/smartgit.helpers.js
vendored
@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
exports.isGitDirectory = function (dirPathArg) {
|
|
||||||
try {
|
|
||||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(dirPathArg, ".git"));
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsc0JBQWMsR0FBRyxVQUFDLFVBQVU7SUFDbkMsSUFBSSxDQUFDO1FBQ0QsTUFBTSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFdBQVcsQ0FDbkMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFDLE1BQU0sQ0FBQyxDQUN2QyxDQUFDO0lBQ04sQ0FDQTtJQUFBLEtBQUssQ0FBQSxDQUFDLEdBQUcsQ0FBQyxDQUFBLENBQUM7UUFDUCxNQUFNLENBQUMsS0FBSyxDQUFDO0lBQ2pCLENBQUM7QUFDTCxDQUFDLENBQUEifQ==
|
|
1
dist/smartgit.init.d.ts
vendored
1
dist/smartgit.init.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let init: (dirPathArg: string) => any;
|
|
15
dist/smartgit.init.js
vendored
15
dist/smartgit.init.js
vendored
@ -1,15 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
exports.init = function (dirPathArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (typeof dirPathArg == "undefined") {
|
|
||||||
plugins.beautylog.error("smartgit.init requires an absolute directory path!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
plugins.smartfile.fs.ensureDir(dirPathArg);
|
|
||||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git init)");
|
|
||||||
done.resolve(dirPathArg);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LmluaXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFFcEMsWUFBSSxHQUFHLFVBQUMsVUFBaUI7SUFDaEMsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUMsQ0FBQyxPQUFPLFVBQVUsSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ25DLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLG9EQUFvRCxDQUFDLENBQUM7UUFDOUUsTUFBTSxDQUFDO0lBQ1gsQ0FBQztJQUFBLENBQUM7SUFDRixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsVUFBVSxDQUFDLENBQUM7SUFDM0MsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsU0FBTyxVQUFVLGtCQUFlLENBQUMsQ0FBQztJQUN2RCxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQ3pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9
|
|
15
dist/smartgit.plugins.d.ts
vendored
15
dist/smartgit.plugins.d.ts
vendored
@ -1,8 +1,7 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
export import path = require("path");
|
export import path = require('path');
|
||||||
export import beautylog = require("beautylog");
|
export import beautylog = require('beautylog');
|
||||||
export declare let Q: any;
|
export import shelljs = require('shelljs');
|
||||||
export declare let shelljs: any;
|
export import smartfile = require('smartfile');
|
||||||
export import smartfile = require("smartfile");
|
export import smartpath = require('smartpath');
|
||||||
export import smartpath = require("smartpath");
|
export import smartstring = require('smartstring');
|
||||||
export import smartstring = require("smartstring");
|
|
||||||
|
3
dist/smartgit.plugins.js
vendored
3
dist/smartgit.plugins.js
vendored
@ -2,9 +2,8 @@
|
|||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.path = require("path");
|
exports.path = require("path");
|
||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
exports.Q = require("q");
|
|
||||||
exports.shelljs = require("shelljs");
|
exports.shelljs = require("shelljs");
|
||||||
exports.smartfile = require("smartfile");
|
exports.smartfile = require("smartfile");
|
||||||
exports.smartpath = require("smartpath");
|
exports.smartpath = require("smartpath");
|
||||||
exports.smartstring = require("smartstring");
|
exports.smartstring = require("smartstring");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUVWLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ3BDLFNBQUMsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztBQUMxQixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHFDQUEwQztBQUMxQyx5Q0FBOEM7QUFDOUMseUNBQThDO0FBQzlDLDZDQUFrRCJ9
|
1
dist/smartgit.pull.d.ts
vendored
1
dist/smartgit.pull.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let pull: (dirPathArg: string, sourceArg?: string, branchArg?: string) => any;
|
|
19
dist/smartgit.pull.js
vendored
19
dist/smartgit.pull.js
vendored
@ -1,19 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
var helpers = require("./smartgit.helpers");
|
|
||||||
exports.pull = function (dirPathArg, sourceArg, branchArg) {
|
|
||||||
if (sourceArg === void 0) { sourceArg = ""; }
|
|
||||||
if (branchArg === void 0) { branchArg = ""; }
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.pull expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// if everything is allright proceed
|
|
||||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git pull " + sourceArg + " " + branchArg + ")");
|
|
||||||
done.resolve(dirPathArg);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucHVsbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnB1bGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDOUMsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUVuQyxZQUFJLEdBQUcsVUFBQyxVQUFpQixFQUFDLFNBQXFCLEVBQUUsU0FBcUI7SUFBNUMseUJBQXFCLEdBQXJCLGNBQXFCO0lBQUUseUJBQXFCLEdBQXJCLGNBQXFCO0lBQzdFLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsRUFBRSxDQUFBLENBQUMsQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUEsQ0FBQztRQUNwQyxPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyw2Q0FBNkMsQ0FBQyxDQUFDO1FBQ3ZFLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQztRQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7SUFBQSxDQUFDO0lBQ0Ysb0NBQW9DO0lBQ3BDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFNBQU8sVUFBVSxxQkFBZ0IsU0FBUyxTQUFJLFNBQVMsTUFBRyxDQUFDLENBQUM7SUFDakYsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUN6QixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUMifQ==
|
|
1
dist/smartgit.push.d.ts
vendored
1
dist/smartgit.push.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let push: (dirPathArg: string, remoteNameArg?: string, remoteBranchArg?: string) => any;
|
|
18
dist/smartgit.push.js
vendored
18
dist/smartgit.push.js
vendored
@ -1,18 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
var helpers = require("./smartgit.helpers");
|
|
||||||
exports.push = function (dirPathArg, remoteNameArg, remoteBranchArg) {
|
|
||||||
if (remoteNameArg === void 0) { remoteNameArg = ""; }
|
|
||||||
if (remoteBranchArg === void 0) { remoteBranchArg = ""; }
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.push expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
// if everything seems allright proceed
|
|
||||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git push " + remoteNameArg + " " + remoteBranchArg + ")");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucHVzaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnB1c2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDOUMsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUVuQyxZQUFJLEdBQUcsVUFBQyxVQUFpQixFQUFFLGFBQXlCLEVBQUUsZUFBMkI7SUFBdEQsNkJBQXlCLEdBQXpCLGtCQUF5QjtJQUFFLCtCQUEyQixHQUEzQixvQkFBMkI7SUFDeEYsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3BDLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLDZDQUE2QyxDQUFDLENBQUM7UUFDdkUsSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDO1FBQ2QsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQztJQUNELHVDQUF1QztJQUN2QyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUscUJBQWdCLGFBQWEsU0FBSSxlQUFlLE1BQUcsQ0FBQyxDQUFDO0lBQzNGLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9
|
|
5
dist/smartgit.remote.d.ts
vendored
5
dist/smartgit.remote.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
export declare let remote: {
|
|
||||||
add: (dirPathArg: any, remoteNameArg: string, remoteLinkArg: string) => any;
|
|
||||||
list: (dirPathArg: any) => any;
|
|
||||||
remove: (dirPathArg: string) => any;
|
|
||||||
};
|
|
61
dist/smartgit.remote.js
vendored
61
dist/smartgit.remote.js
vendored
@ -1,61 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
var helpers = require("./smartgit.helpers");
|
|
||||||
var add = function (dirPathArg, remoteNameArg, remoteLinkArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.remote.add expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
if (!remoteNameArg) {
|
|
||||||
plugins.beautylog.error("smartgit.remote.add expects a valid remote name");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
if (!remoteLinkArg) {
|
|
||||||
plugins.beautylog.error("smartgit.remote.add expects a valid remote link");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// if everything is all right proceed
|
|
||||||
plugins.shelljs.exec("cd " + dirPathArg + " && git remote add " + remoteNameArg + " " + remoteLinkArg);
|
|
||||||
exports.remote.list(dirPathArg);
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
var check = function (dirPathArg, remoteNameArg, remoteLinkArg) {
|
|
||||||
};
|
|
||||||
var list = function (dirPathArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
var remotes = {};
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.remote.list expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// if everything is all right proceed
|
|
||||||
plugins.shelljs.exec("cd " + dirPathArg + " && git remote -v").stdout;
|
|
||||||
done.resolve(remotes);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
var remove = function (dirPathArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.remote.remove expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// if everything is all right
|
|
||||||
};
|
|
||||||
exports.remote = {
|
|
||||||
add: add,
|
|
||||||
list: list,
|
|
||||||
remove: remove
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucmVtb3RlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQucmVtb3RlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFOUMsSUFBSSxHQUFHLEdBQUcsVUFBQyxVQUFVLEVBQUMsYUFBb0IsRUFBRSxhQUFvQjtJQUM1RCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQSxDQUFDLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUF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0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLDhCQUE4QjtBQUNsQyxDQUFDLENBQUE7QUFFVSxjQUFNLEdBQUc7SUFDaEIsR0FBRyxFQUFFLEdBQUc7SUFDUixJQUFJLEVBQUUsSUFBSTtJQUNWLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ==
|
|
1
dist/smartgit.status.d.ts
vendored
1
dist/smartgit.status.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let status: (dirPathArg: string) => any;
|
|
16
dist/smartgit.status.js
vendored
16
dist/smartgit.status.js
vendored
@ -1,16 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartgit.plugins");
|
|
||||||
var helpers = require("./smartgit.helpers");
|
|
||||||
exports.status = function (dirPathArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
|
||||||
plugins.beautylog.error("smartgit.status expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
// if everything seems allright proceed
|
|
||||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git status)");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuc3RhdHVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuc3RhdHVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsY0FBTSxHQUFHLFVBQUMsVUFBaUI7SUFDbEMsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3BDLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLCtDQUErQyxDQUFDLENBQUM7UUFDekUsSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDO1FBQ2QsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQztJQUNELHVDQUF1QztJQUN2QyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsb0JBQWlCLENBQUMsQ0FBQztJQUN6RCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7SUFDZixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUMifQ==
|
|
12
npmextra.json
Normal file
12
npmextra.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"npmts": {
|
||||||
|
"mode": "default",
|
||||||
|
"codecov": true,
|
||||||
|
"coverageTreshold": 71
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"globalNpmTools": [
|
||||||
|
"npmts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"mode":"default",
|
|
||||||
"codecov":true,
|
|
||||||
"coverageTreshold":71
|
|
||||||
}
|
|
28
package.json
28
package.json
@ -1,13 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "smartgit",
|
"name": "smartgit",
|
||||||
"version": "0.1.8",
|
"version": "1.0.5",
|
||||||
"description": "an easy wrapper for git",
|
"description": "smart git wrapper for node",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cleanTest": "rm -rf test/temp*",
|
"cleanTest": "rm -rf test/temp*",
|
||||||
"test": "(npm run cleanTest && npmts)",
|
"test": "(npm run cleanTest && npmts)"
|
||||||
"install": "node dist/postinstall.js"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -26,17 +25,20 @@
|
|||||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/minimatch": "*",
|
"@types/minimatch": "*",
|
||||||
"beautylog": "^5.0.13",
|
"@types/shelljs": "^0.3.32",
|
||||||
|
"beautylog": "^6.0.0",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"shelljs": "^0.7.0",
|
"shelljs": "^0.7.5",
|
||||||
"smartfile": "^4.0.10",
|
"simple-git": "^1.62.0",
|
||||||
"smartpath": "^3.2.2",
|
"smartfile": "^4.1.0",
|
||||||
"smartstring": "^2.0.10",
|
"smartpath": "^3.2.5",
|
||||||
"typings-global": "^1.0.5"
|
"smartstring": "^2.0.22",
|
||||||
|
"typings-global": "^1.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.6",
|
"@types/should": "^8.1.30",
|
||||||
"should": "^9.0.2",
|
"npmts-g": "^5.2.8",
|
||||||
"typings-test": "^1.0.1"
|
"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 'typings-test';
|
||||||
import "should";
|
|
||||||
|
144
test/test.js
144
test/test.js
@ -1,84 +1,110 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-test");
|
require("typings-test");
|
||||||
var shelljs = require("shelljs");
|
let shelljs = require('shelljs');
|
||||||
var path = require("path");
|
const path = require("path");
|
||||||
require("should");
|
const should = require("should");
|
||||||
var smartgit = require("../dist/index");
|
const smartgit = require("../dist/index");
|
||||||
var paths = {
|
let paths = {
|
||||||
temp: path.resolve("./test/temp/"),
|
temp1: path.resolve('./test/temp/'),
|
||||||
temp2: path.resolve("./test/temp2/"),
|
temp2: path.resolve('./test/temp2/'),
|
||||||
temp3: path.resolve("./test/temp3"),
|
temp3: path.resolve('./test/temp3'),
|
||||||
temp4: path.resolve("./test/temp4"),
|
temp4: path.resolve('./test/temp4'),
|
||||||
noGit: path.resolve("./test/")
|
noGit: path.resolve('./test/')
|
||||||
};
|
};
|
||||||
describe("smartgit", function () {
|
describe('smartgit', function () {
|
||||||
describe(".clone", function () {
|
let testGitRepo;
|
||||||
it("should clone a repository using ssh and sshkey", function (done) {
|
let testGitRepoCloned;
|
||||||
this.timeout(40000);
|
let testGitRepoInit;
|
||||||
smartgit.clone({
|
describe('instance', function () {
|
||||||
from: "git@gitlab.com:sandboxzone/sandbox-testrepo.git",
|
it('should error for invalid path', function (done) {
|
||||||
to: paths.temp
|
try {
|
||||||
}).then(function () {
|
testGitRepo = new smartgit.GitRepo(paths.temp1);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo);
|
||||||
done();
|
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) {
|
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);
|
this.timeout(40000);
|
||||||
smartgit.clone({
|
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp2)
|
||||||
from: "https://gitlab.com/sandboxzone/sandbox-testrepo.git",
|
.then((gitRepo) => {
|
||||||
to: paths.temp2
|
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
||||||
}).then(function () {
|
|
||||||
done();
|
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 () {
|
describe('.add', function () {
|
||||||
it("should error for noGit", function () {
|
it('should add a file to an existing repository', function () {
|
||||||
smartgit.add.addAll(paths.noGit);
|
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`);
|
||||||
});
|
testGitRepo.addAll();
|
||||||
it("should add a file to an existing repository", function () {
|
|
||||||
shelljs.exec("(cd " + paths.temp + " && cp ../test.js .)");
|
|
||||||
smartgit.add.addAll(paths.temp);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("commit", function () {
|
describe('.check()', function () {
|
||||||
it("should error for noGit", function () {
|
it('should check a git repo', function () {
|
||||||
smartgit.commit(paths.noGit, "some commit message");
|
let checkResult = testGitRepo.check();
|
||||||
});
|
should(checkResult).be.true();
|
||||||
it("should commit a new file to an existing repository", function () {
|
|
||||||
smartgit.commit(paths.temp, "added a new file");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("init", function () {
|
describe('commit', function () {
|
||||||
it("should error for noGit", function () {
|
it('should commit a new file to an existing repository', function () {
|
||||||
smartgit.init(paths.noGit);
|
testGitRepo.commit('added a new file');
|
||||||
});
|
|
||||||
it("should init a new git", function () {
|
|
||||||
smartgit.init(paths.temp3);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("pull", function () {
|
describe('pull', function () {
|
||||||
this.timeout(40000);
|
this.timeout(40000);
|
||||||
it("should error for noGit", function () {
|
it('should pull from origin', function (done) {
|
||||||
smartgit.pull(paths.noGit);
|
testGitRepo.pull()
|
||||||
});
|
.then(() => {
|
||||||
it("should pull from origin", function () {
|
done();
|
||||||
smartgit.pull(paths.temp);
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("remote", function () {
|
describe('push', function () {
|
||||||
it("should error for noGit", function () {
|
this.timeout(40000);
|
||||||
smartgit.remote.add(paths.noGit, null, null);
|
it('should push to origin', function (done) {
|
||||||
|
testGitRepo.push('origin', 'master')
|
||||||
|
.then(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it("should error for no remote name", function () {
|
});
|
||||||
smartgit.remote.add(paths.temp, null, null);
|
describe('remote', function () {
|
||||||
|
it('should add a remote', function () {
|
||||||
|
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo');
|
||||||
});
|
});
|
||||||
it("should error for no remote link", function () {
|
it('should', function (done) {
|
||||||
smartgit.remote.add(paths.temp, "origin", null);
|
testGitRepo.remoteList()
|
||||||
});
|
.then(() => {
|
||||||
it("should add a remote", function () {
|
done();
|
||||||
smartgit.remote.add(paths.temp, "origin2", "https://github.com/pushrocks/somerepo");
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdX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 +1,112 @@
|
|||||||
import "typings-test";
|
import 'typings-test'
|
||||||
import beautylog = require("beautylog");
|
import beautylog = require('beautylog')
|
||||||
let shelljs = require("shelljs");
|
let shelljs = require('shelljs')
|
||||||
import path = require("path");
|
import path = require('path')
|
||||||
import "should"
|
import * as should from 'should'
|
||||||
|
|
||||||
import smartgit = require("../dist/index");
|
import smartgit = require('../dist/index')
|
||||||
let paths = {
|
let paths = {
|
||||||
temp: path.resolve("./test/temp/"),
|
temp1: path.resolve('./test/temp/'),
|
||||||
temp2: path.resolve("./test/temp2/"),
|
temp2: path.resolve('./test/temp2/'),
|
||||||
temp3: path.resolve("./test/temp3"),
|
temp3: path.resolve('./test/temp3'),
|
||||||
temp4: path.resolve("./test/temp4"),
|
temp4: path.resolve('./test/temp4'),
|
||||||
noGit: path.resolve("./test/")
|
noGit: path.resolve('./test/')
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("smartgit",function(){
|
|
||||||
describe(".clone",function(){
|
|
||||||
it("should clone a repository using ssh and sshkey",function(done){
|
describe('smartgit', function () {
|
||||||
this.timeout(40000);
|
let testGitRepo: smartgit.GitRepo
|
||||||
smartgit.clone({
|
let testGitRepoCloned: smartgit.GitRepo
|
||||||
from:"git@gitlab.com:sandboxzone/sandbox-testrepo.git",
|
let testGitRepoInit: smartgit.GitRepo
|
||||||
to:paths.temp
|
describe('instance', function () {
|
||||||
}).then(function(){
|
it('should error for invalid path', function (done) {
|
||||||
done();
|
try {
|
||||||
});
|
testGitRepo = new smartgit.GitRepo(paths.temp1)
|
||||||
});
|
} catch (err) {
|
||||||
it("should clone a repository using https",function(done){
|
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo)
|
||||||
this.timeout(40000);
|
done()
|
||||||
smartgit.clone({
|
}
|
||||||
from:"https://gitlab.com/sandboxzone/sandbox-testrepo.git",
|
|
||||||
to:paths.temp2
|
|
||||||
}).then(function(){
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".add",function(){
|
|
||||||
it("should error for noGit",function(){
|
|
||||||
smartgit.add.addAll(paths.noGit);
|
|
||||||
})
|
})
|
||||||
it("should add a file to an existing repository",function(){
|
it('should init a new repo', function (done) {
|
||||||
shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`)
|
this.timeout(40000)
|
||||||
smartgit.add.addAll(paths.temp);
|
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 () {
|
||||||
describe("commit",function(){
|
testGitRepo = new smartgit.GitRepo(paths.temp1)
|
||||||
it("should error for noGit",function(){
|
should(testGitRepo).be.instanceOf(smartgit.GitRepo)
|
||||||
smartgit.commit(paths.noGit,"some commit message");
|
|
||||||
})
|
})
|
||||||
it("should commit a new file to an existing repository",function(){
|
it('should clone a repository using ssh and sshkey', function (done) {
|
||||||
smartgit.commit(paths.temp,"added a new file");
|
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) {
|
||||||
describe("init",function(){
|
this.timeout(40000)
|
||||||
it("should error for noGit",function(){
|
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp3)
|
||||||
smartgit.init(paths.noGit);
|
.then((gitRepo) => {
|
||||||
});
|
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
||||||
it("should init a new git",function(){
|
done()
|
||||||
smartgit.init(paths.temp3);
|
}).catch(err => {
|
||||||
|
throw err
|
||||||
|
})
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
describe("pull",function(){
|
describe('.add', function () {
|
||||||
this.timeout(40000);
|
it('should add a file to an existing repository', function () {
|
||||||
it("should error for noGit",function(){
|
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`)
|
||||||
smartgit.pull(paths.noGit);
|
testGitRepo.addAll()
|
||||||
});
|
|
||||||
it("should pull from origin",function(){
|
|
||||||
smartgit.pull(paths.temp);
|
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
describe("remote",function(){
|
describe('.check()', function() {
|
||||||
it("should error for noGit",function(){
|
it('should check a git repo', function() {
|
||||||
smartgit.remote.add(paths.noGit,null,null);
|
let checkResult = testGitRepo.check()
|
||||||
});
|
should(checkResult).be.true()
|
||||||
it("should error for no remote name",function(){
|
})
|
||||||
smartgit.remote.add(paths.temp,null,null);
|
})
|
||||||
});
|
describe('commit', function () {
|
||||||
it("should error for no remote link",function(){
|
it('should commit a new file to an existing repository', function () {
|
||||||
smartgit.remote.add(paths.temp,"origin",null);
|
testGitRepo.commit('added a new file')
|
||||||
});
|
})
|
||||||
it("should add a remote",function(){
|
})
|
||||||
smartgit.remote.add(paths.temp,"origin2","https://github.com/pushrocks/somerepo");
|
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()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
37
ts/index.ts
37
ts/index.ts
@ -1,10 +1,31 @@
|
|||||||
|
import * as q from 'q'
|
||||||
import plugins = require("./smartgit.plugins");
|
import plugins = require("./smartgit.plugins");
|
||||||
|
|
||||||
export {add} from "./smartgit.add";
|
import { GitRepo } from './smartgit.classes.gitrepo'
|
||||||
export {clone} from "./smartgit.clone";
|
export {
|
||||||
export {commit} from "./smartgit.commit";
|
GitRepo
|
||||||
export {init} from "./smartgit.init";
|
}
|
||||||
export {pull} from "./smartgit.pull";
|
|
||||||
export {push} from "./smartgit.push";
|
/**
|
||||||
export {remote} from "./smartgit.remote";
|
* creates a new GitRepo Instance after cloning a project
|
||||||
export {status} from "./smartgit.status";
|
*/
|
||||||
|
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,2 +0,0 @@
|
|||||||
let shelljs = require("shelljs");
|
|
||||||
import beautylog = require("beautylog");
|
|
@ -1,19 +0,0 @@
|
|||||||
import * as plugins from "./smartgit.plugins";
|
|
||||||
import * as helpers from "./smartgit.helpers";
|
|
||||||
|
|
||||||
let addAll = (dirPathArg:string) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.add expects a valid git directory!");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
// if everything is ok proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`);
|
|
||||||
done.resolve(dirPathArg);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
export let add = {
|
|
||||||
addAll: addAll
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
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,16 +0,0 @@
|
|||||||
import plugins = require("./smartgit.plugins");
|
|
||||||
import SmartgitCheck = require("./smartgit.check");
|
|
||||||
|
|
||||||
export let clone = (optionsArg: {
|
|
||||||
from: string,
|
|
||||||
to: string,
|
|
||||||
key?: string,
|
|
||||||
keyPath?: string,
|
|
||||||
keyPassphrase?: string
|
|
||||||
}) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
plugins.smartfile.fs.ensureDir(optionsArg.to);
|
|
||||||
plugins.shelljs.exec(`git clone ${optionsArg.from} ${optionsArg.to}`);
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
@ -1,15 +0,0 @@
|
|||||||
import * as plugins from "./smartgit.plugins";
|
|
||||||
import * as helpers from "./smartgit.helpers";
|
|
||||||
|
|
||||||
export let commit = (dirPathArg:string,commitMessage:string) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.commit expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
// if everything is all right proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git commit -m "${commitMessage}")`);
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
@ -1,12 +0,0 @@
|
|||||||
import * as plugins from "./smartgit.plugins";
|
|
||||||
|
|
||||||
export let isGitDirectory = (dirPathArg):boolean => {
|
|
||||||
try {
|
|
||||||
return plugins.smartfile.fs.isDirectory(
|
|
||||||
plugins.path.join(dirPathArg,".git")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch(err){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
import plugins = require("./smartgit.plugins");
|
|
||||||
|
|
||||||
export let init = (dirPathArg:string) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if (typeof dirPathArg == "undefined") { //lets check if a destination is defined...
|
|
||||||
plugins.beautylog.error("smartgit.init requires an absolute directory path!");
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
plugins.smartfile.fs.ensureDir(dirPathArg);
|
|
||||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git init)`);
|
|
||||||
done.resolve(dirPathArg);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
@ -1,9 +1,7 @@
|
|||||||
import "typings-global";
|
import 'typings-global'
|
||||||
|
export import path = require('path')
|
||||||
export import path = require("path");
|
export import beautylog = require('beautylog')
|
||||||
export import beautylog = require("beautylog");
|
export import shelljs = require('shelljs')
|
||||||
export let Q = require("q");
|
export import smartfile = require('smartfile')
|
||||||
export let shelljs = require("shelljs");
|
export import smartpath = require('smartpath')
|
||||||
export import smartfile = require("smartfile");
|
export import smartstring = require('smartstring')
|
||||||
export import smartpath = require("smartpath");
|
|
||||||
export import smartstring = require("smartstring");
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import * as plugins from "./smartgit.plugins";
|
|
||||||
import * as helpers from "./smartgit.helpers";
|
|
||||||
|
|
||||||
export let pull = (dirPathArg:string,sourceArg:string = "", branchArg:string = "") => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.pull expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
// if everything is allright proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git pull ${sourceArg} ${branchArg})`);
|
|
||||||
done.resolve(dirPathArg);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
@ -1,15 +0,0 @@
|
|||||||
import * as plugins from "./smartgit.plugins";
|
|
||||||
import * as helpers from "./smartgit.helpers";
|
|
||||||
|
|
||||||
export let push = (dirPathArg:string, remoteNameArg:string = "", remoteBranchArg:string = "") => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.push expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
// if everything seems allright proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git push ${remoteNameArg} ${remoteBranchArg})`);
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
@ -1,60 +0,0 @@
|
|||||||
import * as plugins from "./smartgit.plugins";
|
|
||||||
import * as helpers from "./smartgit.helpers";
|
|
||||||
|
|
||||||
let add = (dirPathArg,remoteNameArg:string, remoteLinkArg:string) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.remote.add expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
if(!remoteNameArg) {
|
|
||||||
plugins.beautylog.error("smartgit.remote.add expects a valid remote name");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
if(!remoteLinkArg) {
|
|
||||||
plugins.beautylog.error("smartgit.remote.add expects a valid remote link");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
// if everything is all right proceed
|
|
||||||
plugins.shelljs.exec(`cd ${dirPathArg} && git remote add ${remoteNameArg} ${remoteLinkArg}`);
|
|
||||||
remote.list(dirPathArg);
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
let check = (dirPathArg:string, remoteNameArg:string, remoteLinkArg) => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
let list = (dirPathArg) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
let remotes = {};
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.remote.list expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
// if everything is all right proceed
|
|
||||||
plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`).stdout;
|
|
||||||
done.resolve(remotes);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
let remove = (dirPathArg:string) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.remote.remove expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
// if everything is all right
|
|
||||||
}
|
|
||||||
|
|
||||||
export let remote = {
|
|
||||||
add: add,
|
|
||||||
list: list,
|
|
||||||
remove: remove
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import * as plugins from "./smartgit.plugins";
|
|
||||||
import * as helpers from "./smartgit.helpers";
|
|
||||||
|
|
||||||
export let status = (dirPathArg:string) => {
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
if(!helpers.isGitDirectory(dirPathArg)){
|
|
||||||
plugins.beautylog.error("smartgit.status expects a valid git directory");
|
|
||||||
done.reject();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
// if everything seems allright proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git status)`);
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
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