diff --git a/README.md b/README.md index 8e95669..484e337 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # smartgit -wrapper for git. +smart git wrapper for node. smartgit expects git to be installed on target machine. @@ -19,22 +19,48 @@ smartgit expects git to be installed on target machine. [![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) -## Features: - -* clone a git repo -* init a new repo -* create a new git repo -* add changes and make a new commit -* commit changes -* push changes -* add/remove remotes - ## Usage We recommend the use of TypeScript for best in class intellisense ```javascript -import * as smartgit from 'smartgit' +// 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 diff --git a/dist/index.d.ts b/dist/index.d.ts index dc70258..a33ac28 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,8 +1,12 @@ -export { add } from "./smartgit.add"; -export { clone } from "./smartgit.clone"; -export { commit } from "./smartgit.commit"; -export { init } from "./smartgit.init"; -export { pull } from "./smartgit.pull"; -export { push } from "./smartgit.push"; -export { remote } from "./smartgit.remote"; -export { status } from "./smartgit.status"; +/// +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; +/** + * creates a new GitRepo instance after initializing a new Git Repository + */ +export declare let createRepoFromInit: (destinationDirArg: string) => void; diff --git a/dist/index.js b/dist/index.js index e939595..bf0f291 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,18 +1,27 @@ "use strict"; -var smartgit_add_1 = require("./smartgit.add"); -exports.add = smartgit_add_1.add; -var smartgit_clone_1 = require("./smartgit.clone"); -exports.clone = smartgit_clone_1.clone; -var smartgit_commit_1 = require("./smartgit.commit"); -exports.commit = smartgit_commit_1.commit; -var smartgit_init_1 = require("./smartgit.init"); -exports.init = smartgit_init_1.init; -var smartgit_pull_1 = require("./smartgit.pull"); -exports.pull = smartgit_pull_1.pull; -var smartgit_push_1 = require("./smartgit.push"); -exports.push = smartgit_push_1.push; -var smartgit_remote_1 = require("./smartgit.remote"); -exports.remote = smartgit_remote_1.remote; -var smartgit_status_1 = require("./smartgit.status"); -exports.status = smartgit_status_1.status; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsK0NBQW1DO0FBQTNCLDZCQUFBLEdBQUcsQ0FBQTtBQUNYLG1EQUF1QztBQUEvQixpQ0FBQSxLQUFLLENBQUE7QUFDYixxREFBeUM7QUFBakMsbUNBQUEsTUFBTSxDQUFBO0FBQ2QsaURBQXFDO0FBQTdCLCtCQUFBLElBQUksQ0FBQTtBQUNaLGlEQUFxQztBQUE3QiwrQkFBQSxJQUFJLENBQUE7QUFDWixpREFBcUM7QUFBN0IsK0JBQUEsSUFBSSxDQUFBO0FBQ1oscURBQXlDO0FBQWpDLG1DQUFBLE1BQU0sQ0FBQTtBQUNkLHFEQUF5QztBQUFqQyxtQ0FBQSxNQUFNLENBQUEifQ== \ No newline at end of file +const q = require("q"); +const plugins = require("./smartgit.plugins"); +const smartgit_classes_gitrepo_1 = require("./smartgit.classes.gitrepo"); +exports.GitRepo = smartgit_classes_gitrepo_1.GitRepo; +/** + * creates a new GitRepo Instance after cloning a project + */ +exports.createRepoFromClone = (fromArg, toArg) => { + let done = q.defer(); + plugins.smartfile.fs.ensureDir(toArg); + plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`); + let newRepo = new smartgit_classes_gitrepo_1.GitRepo(toArg); + done.resolve(newRepo); + return done.promise; +}; +/** + * creates a new GitRepo instance after initializing a new Git Repository + */ +exports.createRepoFromInit = (destinationDirArg) => { + let done = q.defer(); + plugins.smartfile.fs.ensureDir(destinationDirArg); + plugins.shelljs.exec(`cd destinationDirArg && git init`); + let newRepo = new smartgit_classes_gitrepo_1.GitRepo(destinationDirArg); + done.resolve(newRepo); +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDhDQUErQztBQUUvQyx5RUFBb0Q7QUFFaEQscURBQU87QUFHWDs7R0FFRztBQUNRLFFBQUEsbUJBQW1CLEdBQUcsQ0FBQyxPQUFlLEVBQUUsS0FBYTtJQUM1RCxJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFXLENBQUE7SUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ3JDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGFBQWEsT0FBTyxJQUFJLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDckQsSUFBSSxPQUFPLEdBQUcsSUFBSSxrQ0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2hDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLGtCQUFrQixHQUFHLENBQUMsaUJBQXlCO0lBQ3RELElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQVcsQ0FBQTtJQUM3QixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUNqRCxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxrQ0FBa0MsQ0FBQyxDQUFBO0lBQ3hELElBQUksT0FBTyxHQUFHLElBQUksa0NBQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQUFBO0lBQzVDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7QUFDekIsQ0FBQyxDQUFBIn0= \ No newline at end of file diff --git a/dist/postinstall.d.ts b/dist/postinstall.d.ts deleted file mode 100644 index e69de29..0000000 diff --git a/dist/postinstall.js b/dist/postinstall.js deleted file mode 100644 index edad5f2..0000000 --- a/dist/postinstall.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -let shelljs = require("shelljs"); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9zdGluc3RhbGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wb3N0aW5zdGFsbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/dist/smartgit.add.d.ts b/dist/smartgit.add.d.ts deleted file mode 100644 index d6ac80f..0000000 --- a/dist/smartgit.add.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -import * as plugins from "./smartgit.plugins"; -export declare let add: { - addAll: (dirPathArg: string) => plugins.Q.Promise<{}>; -}; diff --git a/dist/smartgit.add.js b/dist/smartgit.add.js deleted file mode 100644 index 0a147af..0000000 --- a/dist/smartgit.add.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -const helpers = require("./smartgit.helpers"); -let addAll = (dirPathArg) => { - let done = plugins.Q.defer(); - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.add expects a valid git directory!"); - plugins.beautylog.error(err.message); - done.reject(err); - 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuYWRkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuYWRkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw4Q0FBOEM7QUFDOUMsOENBQThDO0FBRTlDLElBQUksTUFBTSxHQUFHLENBQUMsVUFBaUI7SUFDM0IsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3BDLElBQUksR0FBRyxHQUFHLElBQUksS0FBSyxDQUFDLDZDQUE2QyxDQUFDLENBQUM7UUFDbkUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUM7UUFDakIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQztJQUFBLENBQUM7SUFDRiw4QkFBOEI7SUFDOUIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxVQUFVLCtCQUErQixDQUFDLENBQUM7SUFDdkUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUN6QixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUM7QUFFUyxRQUFBLEdBQUcsR0FBRztJQUNiLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ== \ No newline at end of file diff --git a/dist/smartgit.check.d.ts b/dist/smartgit.check.d.ts deleted file mode 100644 index 215dfd6..0000000 --- a/dist/smartgit.check.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare var _default: (repoArg: any) => boolean; -export = _default; diff --git a/dist/smartgit.check.js b/dist/smartgit.check.js deleted file mode 100644 index 1378c26..0000000 --- a/dist/smartgit.check.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; -module.exports = function (repoArg) { - return true; -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY2hlY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGdpdC5jaGVjay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsaUJBQVMsVUFBUyxPQUFPO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUM7QUFDaEIsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/dist/smartgit.classes.gitrepo.d.ts b/dist/smartgit.classes.gitrepo.d.ts new file mode 100644 index 0000000..9a3e810 --- /dev/null +++ b/dist/smartgit.classes.gitrepo.d.ts @@ -0,0 +1,57 @@ +/// +import * as q from 'q'; +/** + * class GitRepo allows access to git directories from node + */ +export declare class GitRepo { + repoBase: string; + constructor(repoBaseArg: string); + /** + * checks if the Repo is valid + */ + check(): boolean; + /** + * stage all files in working directory + */ + addAll(dirPathArg: string): q.Promise<{}>; + /** + * add a remote to the GitRepo + */ + remoteAdd(remoteNameArg: string, remoteLinkArg: string): q.Promise<{}>; + /** + * list remotes for a Gip + */ + remoteList(dirPathArg: any): q.Promise<{}>; + /** + * remove remote + */ + remoteRemove(dirPathArg: string): q.Promise<{}>; + /** + * commit all files that are currently staged + */ + commit(commitMessage: string): q.Promise<{}>; + /** + * pull latest changes from remote + */ + pull(sourceArg?: string, branchArg?: string): q.Promise<{}>; + /** + * push new commits to remote + */ + push(remoteNameArg?: string, remoteBranchArg?: string): q.Promise<{}>; + /** + * sync + */ + sync(): void; + /** + * get the current status + */ + status(): q.Promise<{}>; +} +/** + * creates a new GitRepo Instance after cloning a project + */ +export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise; +/** + * creates a new GitRepo instance after initializing a new Git Repository + */ +export declare let createRepoFromInit: (destinationDirArg: string) => void; diff --git a/dist/smartgit.classes.gitrepo.js b/dist/smartgit.classes.gitrepo.js new file mode 100644 index 0000000..04d8785 --- /dev/null +++ b/dist/smartgit.classes.gitrepo.js @@ -0,0 +1,143 @@ +"use strict"; +const q = require("q"); +const plugins = require("./smartgit.plugins"); +/** + * class GitRepo allows access to git directories from node + */ +class GitRepo { + constructor(repoBaseArg) { + this.repoBase = repoBaseArg; + } + /** + * checks if the Repo is valid + */ + check() { + try { + return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git')); + } + catch (err) { + return false; + } + } + /** + * stage all files in working directory + */ + addAll(dirPathArg) { + let done = q.defer(); + plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`); + done.resolve(dirPathArg); + return done.promise; + } + ; + /** + * add a remote to the GitRepo + */ + remoteAdd(remoteNameArg, remoteLinkArg) { + let done = q.defer(); + if (!remoteNameArg) { + let err = new Error('smartgit.remote.add expects a valid remote name'); + plugins.beautylog.error(err.message); + done.reject(err); + return done.promise; + } + ; + if (!remoteLinkArg) { + let err = new Error(); + plugins.beautylog.error(err.message); + done.reject(err); + return done.promise; + } + ; + // if everything is all right proceed + plugins.shelljs.exec(`cd ${this.repoBase} && git remote add ${remoteNameArg} ${remoteLinkArg}`); + done.resolve(); + return done.promise; + } + /** + * list remotes for a Gip + */ + remoteList(dirPathArg) { + let done = q.defer(); + let remotes = {}; + plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`); + done.resolve(remotes); + return done.promise; + } + ; + /** + * remove remote + */ + remoteRemove(dirPathArg) { + let done = q.defer(); + return done.promise; + } + /** + * commit all files that are currently staged + */ + commit(commitMessage) { + 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 = '', branchArg = '') { + 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 = '', remoteBranchArg = '') { + 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; + } +} +exports.GitRepo = GitRepo; +/** + * creates a new GitRepo Instance after cloning a project + */ +exports.createRepoFromClone = (fromArg, toArg) => { + let done = q.defer(); + plugins.smartfile.fs.ensureDir(toArg); + plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`); + let newRepo = new 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 GitRepo(destinationDirArg); + done.resolve(newRepo); +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY2xhc3Nlcy5naXRyZXBvLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuY2xhc3Nlcy5naXRyZXBvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSx1QkFBc0I7QUFDdEIsOENBQTZDO0FBRTdDOztHQUVHO0FBQ0g7SUFFSSxZQUFZLFdBQW1CO1FBQzNCLElBQUksQ0FBQyxRQUFRLEdBQUcsV0FBVyxDQUFBO0lBQy9CLENBQUM7SUFFRDs7T0FFRztJQUNILEtBQUs7UUFDRCxJQUFJLENBQUM7WUFDRCxNQUFNLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsV0FBVyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQTtRQUNyRixDQUFFO1FBQUEsS0FBSyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztZQUNYLE1BQU0sQ0FBQyxLQUFLLENBQUE7UUFDaE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QUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxrQ0FBa0MsQ0FBQyxDQUFBO0lBQ3hELElBQUksT0FBTyxHQUFHLElBQUksT0FBTyxDQUFDLGlCQUFpQixDQUFDLENBQUE7SUFDNUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtBQUN6QixDQUFDLENBQUEifQ== \ No newline at end of file diff --git a/dist/smartgit.clone.d.ts b/dist/smartgit.clone.d.ts deleted file mode 100644 index 99fee2f..0000000 --- a/dist/smartgit.clone.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -import plugins = require("./smartgit.plugins"); -export declare let clone: (optionsArg: { - from: string; - to: string; - key?: string; - keyPath?: string; - keyPassphrase?: string; -}) => plugins.Q.Promise<{}>; diff --git a/dist/smartgit.clone.js b/dist/smartgit.clone.js deleted file mode 100644 index 174b487..0000000 --- a/dist/smartgit.clone.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -exports.clone = (optionsArg) => { - 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; -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY2xvbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGdpdC5jbG9uZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsOENBQStDO0FBR3BDLFFBQUEsS0FBSyxHQUFHLENBQUMsVUFNbkI7SUFDRyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsRUFBRSxDQUFDLENBQUM7SUFDOUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsYUFBYSxVQUFVLENBQUMsSUFBSSxJQUFJLFVBQVUsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDO0lBQ3RFLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9 \ No newline at end of file diff --git a/dist/smartgit.commit.d.ts b/dist/smartgit.commit.d.ts deleted file mode 100644 index 1eb19fe..0000000 --- a/dist/smartgit.commit.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import * as plugins from "./smartgit.plugins"; -export declare let commit: (dirPathArg: string, commitMessage: string) => plugins.Q.Promise<{}>; diff --git a/dist/smartgit.commit.js b/dist/smartgit.commit.js deleted file mode 100644 index c8db956..0000000 --- a/dist/smartgit.commit.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -const helpers = require("./smartgit.helpers"); -exports.commit = (dirPathArg, commitMessage) => { - let done = plugins.Q.defer(); - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.commit expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY29tbWl0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuY29tbWl0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw4Q0FBOEM7QUFDOUMsOENBQThDO0FBRW5DLFFBQUEsTUFBTSxHQUFHLENBQUMsVUFBaUIsRUFBQyxhQUFvQjtJQUN2RCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQSxDQUFDLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDcEMsSUFBSSxHQUFHLEdBQUcsSUFBSSxLQUFLLENBQUMsK0NBQStDLENBQUMsQ0FBQztRQUNyRSxPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDckMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQztRQUNqQixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLHFDQUFxQztJQUNyQyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLFVBQVUsc0JBQXNCLGFBQWEsSUFBSSxDQUFDLENBQUM7SUFDL0UsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/dist/smartgit.helpers.d.ts b/dist/smartgit.helpers.d.ts deleted file mode 100644 index 3e9b259..0000000 --- a/dist/smartgit.helpers.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare let isGitDirectory: (dirPathArg: any) => boolean; diff --git a/dist/smartgit.helpers.js b/dist/smartgit.helpers.js deleted file mode 100644 index 8f87e03..0000000 --- a/dist/smartgit.helpers.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -exports.isGitDirectory = (dirPathArg) => { - try { - return plugins.smartfile.fs.isDirectory(plugins.path.join(dirPathArg, ".git")); - } - catch (err) { - return false; - } -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDhDQUE4QztBQUVuQyxRQUFBLGNBQWMsR0FBRyxDQUFDLFVBQVU7SUFDbkMsSUFBSSxDQUFDO1FBQ0QsTUFBTSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFdBQVcsQ0FDbkMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFDLE1BQU0sQ0FBQyxDQUN2QyxDQUFDO0lBQ04sQ0FDQTtJQUFBLEtBQUssQ0FBQSxDQUFDLEdBQUcsQ0FBQyxDQUFBLENBQUM7UUFDUCxNQUFNLENBQUMsS0FBSyxDQUFDO0lBQ2pCLENBQUM7QUFDTCxDQUFDLENBQUEifQ== \ No newline at end of file diff --git a/dist/smartgit.init.d.ts b/dist/smartgit.init.d.ts deleted file mode 100644 index be6c18e..0000000 --- a/dist/smartgit.init.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import plugins = require("./smartgit.plugins"); -export declare let init: (dirPathArg: string) => plugins.Q.Promise<{}>; diff --git a/dist/smartgit.init.js b/dist/smartgit.init.js deleted file mode 100644 index f3e963a..0000000 --- a/dist/smartgit.init.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -exports.init = (dirPathArg) => { - let done = plugins.Q.defer(); - if (typeof dirPathArg == "undefined") { - let err = new Error("smartgit.init requires an absolute directory path!"); - plugins.beautylog.error(err.message); - done.reject("err"); - return done.promise; - } - ; - plugins.smartfile.fs.ensureDir(dirPathArg); - plugins.shelljs.exec(`(cd ${dirPathArg} && git init)`); - done.resolve(dirPathArg); - return done.promise; -}; -//# sourceMappingURL=data:application/json;base64,eyJ2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ts @@ -1,8 +1,7 @@ -import "typings-global"; -export import path = require("path"); -export import beautylog = require("beautylog"); -export import Q = require("q"); -export import shelljs = require("shelljs"); -export import smartfile = require("smartfile"); -export import smartpath = require("smartpath"); -export import smartstring = require("smartstring"); +import 'typings-global'; +export import path = require('path'); +export import beautylog = require('beautylog'); +export import shelljs = require('shelljs'); +export import smartfile = require('smartfile'); +export import smartpath = require('smartpath'); +export import smartstring = require('smartstring'); diff --git a/dist/smartgit.plugins.js b/dist/smartgit.plugins.js index eb9fd90..4b1182a 100644 --- a/dist/smartgit.plugins.js +++ b/dist/smartgit.plugins.js @@ -2,9 +2,8 @@ require("typings-global"); exports.path = require("path"); exports.beautylog = require("beautylog"); -exports.Q = require("q"); exports.shelljs = require("shelljs"); exports.smartfile = require("smartfile"); exports.smartpath = require("smartpath"); exports.smartstring = require("smartstring"); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHlCQUE4QjtBQUM5QixxQ0FBMEM7QUFDMUMseUNBQThDO0FBQzlDLHlDQUE4QztBQUM5Qyw2Q0FBa0QifQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHFDQUEwQztBQUMxQyx5Q0FBOEM7QUFDOUMseUNBQThDO0FBQzlDLDZDQUFrRCJ9 \ No newline at end of file diff --git a/dist/smartgit.pull.d.ts b/dist/smartgit.pull.d.ts deleted file mode 100644 index 83c3c7f..0000000 --- a/dist/smartgit.pull.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import * as plugins from "./smartgit.plugins"; -export declare let pull: (dirPathArg: string, sourceArg?: string, branchArg?: string) => plugins.Q.Promise<{}>; diff --git a/dist/smartgit.pull.js b/dist/smartgit.pull.js deleted file mode 100644 index 3eda844..0000000 --- a/dist/smartgit.pull.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -const helpers = require("./smartgit.helpers"); -exports.pull = (dirPathArg, sourceArg = "", branchArg = "") => { - let done = plugins.Q.defer(); - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.pull expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucHVsbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnB1bGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDhDQUE4QztBQUM5Qyw4Q0FBOEM7QUFFbkMsUUFBQSxJQUFJLEdBQUcsQ0FBQyxVQUFpQixFQUFDLFlBQW1CLEVBQUUsRUFBRSxZQUFtQixFQUFFO0lBQzdFLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsRUFBRSxDQUFBLENBQUMsQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUEsQ0FBQztRQUNwQyxJQUFJLEdBQUcsR0FBRyxJQUFJLEtBQUssQ0FBQyw2Q0FBNkMsQ0FBQyxDQUFDO1FBQ25FLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUNyQyxJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQ2pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7SUFBQSxDQUFDO0lBQ0Ysb0NBQW9DO0lBQ3BDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sVUFBVSxnQkFBZ0IsU0FBUyxJQUFJLFNBQVMsR0FBRyxDQUFDLENBQUM7SUFDakYsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUN6QixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/dist/smartgit.push.d.ts b/dist/smartgit.push.d.ts deleted file mode 100644 index 8e189df..0000000 --- a/dist/smartgit.push.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import * as plugins from "./smartgit.plugins"; -export declare let push: (dirPathArg: string, remoteNameArg?: string, remoteBranchArg?: string) => plugins.Q.Promise<{}>; diff --git a/dist/smartgit.push.js b/dist/smartgit.push.js deleted file mode 100644 index 0ad4f8d..0000000 --- a/dist/smartgit.push.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -const helpers = require("./smartgit.helpers"); -exports.push = (dirPathArg, remoteNameArg = "", remoteBranchArg = "") => { - let done = plugins.Q.defer(); - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.push expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucHVzaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnB1c2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDhDQUE4QztBQUM5Qyw4Q0FBOEM7QUFFbkMsUUFBQSxJQUFJLEdBQUcsQ0FBQyxVQUFpQixFQUFFLGdCQUF1QixFQUFFLEVBQUUsa0JBQXlCLEVBQUU7SUFDeEYsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3BDLElBQUksR0FBRyxHQUFHLElBQUksS0FBSyxDQUFDLDZDQUE2QyxDQUFDLENBQUM7UUFDbkUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUM7UUFDakIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQztJQUNELHVDQUF1QztJQUN2QyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLFVBQVUsZ0JBQWdCLGFBQWEsSUFBSSxlQUFlLEdBQUcsQ0FBQyxDQUFDO0lBQzNGLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9 \ No newline at end of file diff --git a/dist/smartgit.remote.d.ts b/dist/smartgit.remote.d.ts deleted file mode 100644 index e1ae28c..0000000 --- a/dist/smartgit.remote.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -import * as plugins from "./smartgit.plugins"; -export declare let remote: { - add: (dirPathArg: any, remoteNameArg: string, remoteLinkArg: string) => plugins.Q.Promise<{}>; - list: (dirPathArg: any) => plugins.Q.Promise<{}>; - remove: (dirPathArg: string) => plugins.Q.Promise<{}>; -}; diff --git a/dist/smartgit.remote.js b/dist/smartgit.remote.js deleted file mode 100644 index 990aead..0000000 --- a/dist/smartgit.remote.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -const helpers = require("./smartgit.helpers"); -let add = (dirPathArg, remoteNameArg, remoteLinkArg) => { - let done = plugins.Q.defer(); - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.remote.add expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - return done.promise; - } - ; - 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 ${dirPathArg} && git remote add ${remoteNameArg} ${remoteLinkArg}`); - exports.remote.list(dirPathArg); - done.resolve(); - return done.promise; -}; -let check = (dirPathArg, remoteNameArg, remoteLinkArg) => { -}; -let list = (dirPathArg) => { - let done = plugins.Q.defer(); - let remotes = {}; - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.remote.list expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - 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) => { - let done = plugins.Q.defer(); - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.remote.remove expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - return done.promise; - } - ; - // if everything is all right -}; -exports.remote = { - add: add, - list: list, - remove: remove -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucmVtb3RlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQucmVtb3RlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw4Q0FBOEM7QUFDOUMsOENBQThDO0FBRTlDLElBQUksR0FBRyxHQUFHLENBQUMsVUFBVSxFQUFDLGFBQW9CLEVBQUUsYUFBb0I7SUFDNUQsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3BDLElBQUksR0FBRyxHQUFHLElBQUksS0FBSyxDQUFDLG1EQUFtRCxDQUFDLENBQUM7UUFDekUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUM7UUFDakIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQztJQUFBLENBQUM7SUFDRixFQUFFLENBQUEsQ0FBQyxDQUFDLGFBQWEsQ0FBQyxDQUFDLENBQUM7UUFDaEIsSUFBSSxHQUFHLEdBQUcsSUFBSSxLQUFLLENBQUMsaURBQWlELENBQUMsQ0FBQztRQUN2RSxPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsT0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UFDO0lBQUEsQ0FBQztJQUNGLDhCQUE4QjtBQUNsQyxDQUFDLENBQUE7QUFFVSxRQUFBLE1BQU0sR0FBRztJQUNoQixHQUFHLEVBQUUsR0FBRztJQUNSLElBQUksRUFBRSxJQUFJO0lBQ1YsTUFBTSxFQUFFLE1BQU07Q0FDakIsQ0FBQSJ9 \ No newline at end of file diff --git a/dist/smartgit.status.d.ts b/dist/smartgit.status.d.ts deleted file mode 100644 index 86d4af4..0000000 --- a/dist/smartgit.status.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import * as plugins from "./smartgit.plugins"; -export declare let status: (dirPathArg: string) => plugins.Q.Promise<{}>; diff --git a/dist/smartgit.status.js b/dist/smartgit.status.js deleted file mode 100644 index d82cd51..0000000 --- a/dist/smartgit.status.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -const plugins = require("./smartgit.plugins"); -const helpers = require("./smartgit.helpers"); -exports.status = (dirPathArg) => { - let done = plugins.Q.defer(); - if (!helpers.isGitDirectory(dirPathArg)) { - let err = new Error("smartgit.status expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuc3RhdHVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuc3RhdHVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw4Q0FBOEM7QUFDOUMsOENBQThDO0FBRW5DLFFBQUEsTUFBTSxHQUFHLENBQUMsVUFBaUI7SUFDbEMsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3BDLElBQUksR0FBRyxHQUFHLElBQUksS0FBSyxDQUFDLCtDQUErQyxDQUFDLENBQUM7UUFDckUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUM7UUFDakIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQztJQUFBLENBQUM7SUFDRix1Q0FBdUM7SUFDdkMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxVQUFVLGlCQUFpQixDQUFDLENBQUM7SUFDekQsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/package.json b/package.json index bc887ae..1a52ebf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "smartgit", "version": "0.1.10", - "description": "an easy wrapper for git", + "description": "smart git wrapper for node", "main": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { diff --git a/test/test.d.ts b/test/test.d.ts index e7cc8ee..2fd432a 100644 --- a/test/test.d.ts +++ b/test/test.d.ts @@ -1 +1 @@ -import "typings-test"; +import 'typings-test'; diff --git a/test/test.js b/test/test.js index 8d40100..f0da553 100644 --- a/test/test.js +++ b/test/test.js @@ -1,92 +1,79 @@ "use strict"; require("typings-test"); -let shelljs = require("shelljs"); +let shelljs = require('shelljs'); const path = require("path"); +const should = require("should"); const smartgit = require("../dist/index"); let paths = { - temp: path.resolve("./test/temp/"), - temp2: path.resolve("./test/temp2/"), - temp3: path.resolve("./test/temp3"), - temp4: path.resolve("./test/temp4"), - noGit: path.resolve("./test/") + temp: path.resolve('./test/temp/'), + temp2: path.resolve('./test/temp2/'), + temp3: path.resolve('./test/temp3'), + temp4: path.resolve('./test/temp4'), + noGit: path.resolve('./test/') }; -describe("smartgit", function () { - describe(".clone", function () { - it("should clone a repository using ssh and sshkey", function (done) { +describe('smartgit', function () { + let testGitRepo; + let testGitRepoCloned; + let testGitRepoInit; + describe('instance', function () { + it('should create a valid new instance from path', function () { + testGitRepo = new smartgit.GitRepo('path.temp'); + should(testGitRepo).be.instanceOf(smartgit.GitRepo); + }); + it('should clone a repository using ssh and sshkey', function (done) { this.timeout(40000); - smartgit.clone({ - from: "git@gitlab.com:sandboxzone/sandbox-testrepo.git", - to: paths.temp - }).then(function () { + smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp) + .then((gitRepo) => { + should(gitRepo).be.instanceOf(smartgit.GitRepo); done(); + }).catch(err => { + throw err; }); }); - it("should clone a repository using https", function (done) { + it('should clone a repository using https', function (done) { this.timeout(40000); - smartgit.clone({ - from: "https://gitlab.com/sandboxzone/sandbox-testrepo.git", - to: paths.temp2 - }).then(function () { + smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp2) + .then((gitRepo) => { + should(gitRepo).be.instanceOf(smartgit.GitRepo); done(); + }).catch(err => { + throw err; }); }); }); - describe(".add", function () { - it("should error for noGit", function () { - smartgit.add.addAll(paths.noGit); - }); - it("should add a file to an existing repository", function () { + describe('.add', function () { + it('should add a file to an existing repository', function () { shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`); - smartgit.add.addAll(paths.temp); + testGitRepo.addAll(paths.temp); }); }); - describe("commit", function () { - it("should error for noGit", function () { - smartgit.commit(paths.noGit, "some commit message"); - }); - it("should commit a new file to an existing repository", function () { - smartgit.commit(paths.temp, "added a new file"); + describe('commit', function () { + it('should commit a new file to an existing repository', function () { + testGitRepo.commit('added a new file'); }); }); - describe("init", function () { - it("should error for noGit", function () { - smartgit.init(paths.noGit); - }); - it("should init a new git", function () { - smartgit.init(paths.temp3); - }); - }); - describe("pull", function () { + describe('pull', function () { this.timeout(40000); - it("should error for noGit", function () { - smartgit.pull(paths.noGit); - }); - it("should pull from origin", function () { - smartgit.pull(paths.temp); + it('should pull from origin', function (done) { + testGitRepo.pull() + .then(() => { + done(); + }); }); }); - describe("push", function () { + describe('push', function () { this.timeout(40000); - it("should error for noGit", function () { - smartgit.push(paths.noGit); - }); - it("should push to origin", function () { - smartgit.push(paths.temp, "origin", "master"); + it('should push to origin', function (done) { + testGitRepo.push('origin', 'master') + .then(() => { + done(); + }); }); }); - describe("remote", function () { - it("should error for noGit", function () { - smartgit.remote.add(paths.noGit, null, null); - }); - it("should error for no remote name", function () { - smartgit.remote.add(paths.temp, null, null); - }); - it("should error for no remote link", function () { - smartgit.remote.add(paths.temp, "origin", null); - }); - it("should add a remote", function () { - smartgit.remote.add(paths.temp, "origin2", "https://github.com/pushrocks/somerepo"); + describe('remote', function () { + it('should add a remote', function () { + testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo'); }); }); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQixJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDakMsNkJBQThCO0FBRzlCLDBDQUEyQztBQUMzQyxJQUFJLEtBQUssR0FBRztJQUNSLElBQUksRUFBRSxJQUFJLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQztJQUNsQyxLQUFLLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxlQUFlLENBQUM7SUFDcEMsS0FBSyxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDO0lBQ25DLEtBQUssRUFBRSxJQUFJ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1lBQ1YsQ0FBQyxDQUFDLENBQUE7UUFDVixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0lBQ0YsUUFBUSxDQUFDLE1BQU0sRUFBRTtRQUNiLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsRUFBRSxDQUFDLHVCQUF1QixFQUFFLFVBQVUsSUFBSTtZQUN0QyxXQUFXLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRSxRQUFRLENBQUM7aUJBQy9CLElBQUksQ0FBQztnQkFDRixJQUFJLEVBQUUsQ0FBQTtZQUNWLENBQUMsQ0FBQyxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxRQUFRLEVBQUU7UUFDZixFQUFFLENBQUMscUJBQXFCLEVBQUU7WUFDdEIsV0FBVyxDQUFDLFNBQVMsQ0FBQyxTQUFTLEVBQUUsdUNBQXVDLENBQUMsQ0FBQTtRQUM3RSxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ== \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index ac1ff09..d6ff32f 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,94 +1,80 @@ -import "typings-test" -import beautylog = require("beautylog"); -let shelljs = require("shelljs"); -import path = require("path"); -import * as should from "should" +import 'typings-test' +import beautylog = require('beautylog') +let shelljs = require('shelljs') +import path = require('path') +import * as should from 'should' -import smartgit = require("../dist/index"); +import smartgit = require('../dist/index') let paths = { - temp: path.resolve("./test/temp/"), - temp2: path.resolve("./test/temp2/"), - temp3: path.resolve("./test/temp3"), - temp4: path.resolve("./test/temp4"), - noGit: path.resolve("./test/") + temp: path.resolve('./test/temp/'), + temp2: path.resolve('./test/temp2/'), + temp3: path.resolve('./test/temp3'), + temp4: path.resolve('./test/temp4'), + noGit: path.resolve('./test/') } -describe("smartgit",function(){ - describe(".clone",function(){ - it("should clone a repository using ssh and sshkey",function(done){ - this.timeout(40000); - smartgit.clone({ - from:"git@gitlab.com:sandboxzone/sandbox-testrepo.git", - to:paths.temp - }).then(function(){ - done(); - }); - }); - it("should clone a repository using https",function(done){ - this.timeout(40000); - 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); +describe('smartgit', function () { + let testGitRepo: smartgit.GitRepo + let testGitRepoCloned: smartgit.GitRepo + let testGitRepoInit: smartgit.GitRepo + describe('instance', function () { + it('should create a valid new instance from path', function () { + testGitRepo = new smartgit.GitRepo('path.temp') + should(testGitRepo).be.instanceOf(smartgit.GitRepo) }) - it("should add a file to an existing repository",function(){ + it('should clone a repository using ssh and sshkey', function (done) { + this.timeout(40000) + smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp) + .then((gitRepo) => { + should(gitRepo).be.instanceOf(smartgit.GitRepo) + done() + }).catch(err => { + throw err + }) + }) + it('should clone a repository using https', function (done) { + this.timeout(40000) + smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp2) + .then((gitRepo) => { + should(gitRepo).be.instanceOf(smartgit.GitRepo) + done() + }).catch(err => { + throw err + }) + }) + }) + describe('.add', function () { + it('should add a file to an existing repository', function () { shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`) - smartgit.add.addAll(paths.temp); + testGitRepo.addAll(paths.temp) }) - }); - describe("commit",function(){ - it("should error for noGit",function(){ - smartgit.commit(paths.noGit,"some commit message"); + }) + describe('commit', function () { + it('should commit a new file to an existing repository', function () { + testGitRepo.commit('added a new file') }) - it("should commit a new file to an existing repository",function(){ - smartgit.commit(paths.temp,"added a new file"); + }) + describe('pull', function () { + this.timeout(40000) + it('should pull from origin', function (done) { + testGitRepo.pull() + .then(() => { + done() + }) }) - }); - describe("init",function(){ - it("should error for noGit",function(){ - smartgit.init(paths.noGit); - }); - it("should init a new git",function(){ - smartgit.init(paths.temp3); + }) + describe('push', function () { + this.timeout(40000) + it('should push to origin', function (done) { + testGitRepo.push('origin', 'master') + .then(() => { + done() + }) }) - }); - describe("pull",function(){ - this.timeout(40000); - it("should error for noGit",function(){ - smartgit.pull(paths.noGit); - }); - it("should pull from origin",function(){ - smartgit.pull(paths.temp); + }) + describe('remote', function () { + it('should add a remote', function () { + testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo') }) - }); - describe("push",function(){ - this.timeout(40000); - it("should error for noGit",function(){ - smartgit.push(paths.noGit); - }); - it("should push to origin",function(){ - smartgit.push(paths.temp,"origin","master"); - }) - }); - describe("remote",function(){ - it("should error for noGit",function(){ - smartgit.remote.add(paths.noGit,null,null); - }); - it("should error for no remote name",function(){ - smartgit.remote.add(paths.temp,null,null); - }); - it("should error for no remote link",function(){ - smartgit.remote.add(paths.temp,"origin",null); - }); - it("should add a remote",function(){ - smartgit.remote.add(paths.temp,"origin2","https://github.com/pushrocks/somerepo"); - }); - }); -}); \ No newline at end of file + }) +}) diff --git a/ts/index.ts b/ts/index.ts index c571037..5bc1971 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,3 +1,30 @@ +import * as q from 'q' import plugins = require("./smartgit.plugins"); -export * from './smartgit.classes.smartgit' +import { GitRepo } from './smartgit.classes.gitrepo' +export { + GitRepo +} + +/** + * creates a new GitRepo Instance after cloning a project + */ +export let createRepoFromClone = (fromArg: string, toArg: string) => { + let done = q.defer() + 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() + plugins.smartfile.fs.ensureDir(destinationDirArg) + plugins.shelljs.exec(`cd destinationDirArg && git init`) + let newRepo = new GitRepo(destinationDirArg) + done.resolve(newRepo) +} diff --git a/ts/postinstall.ts b/ts/postinstall.ts deleted file mode 100644 index 104e198..0000000 --- a/ts/postinstall.ts +++ /dev/null @@ -1,2 +0,0 @@ -let shelljs = require("shelljs"); -import beautylog = require("beautylog"); \ No newline at end of file diff --git a/ts/smartgit.add.ts b/ts/smartgit.add.ts deleted file mode 100644 index c181845..0000000 --- a/ts/smartgit.add.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as plugins from "./smartgit.plugins"; - -export let add = { - addAll: addAll -} diff --git a/ts/smartgit.classes.smartgit.ts b/ts/smartgit.classes.gitrepo.ts similarity index 61% rename from ts/smartgit.classes.smartgit.ts rename to ts/smartgit.classes.gitrepo.ts index f112b02..13dd0b3 100644 --- a/ts/smartgit.classes.smartgit.ts +++ b/ts/smartgit.classes.gitrepo.ts @@ -31,6 +31,49 @@ export class GitRepo { return done.promise }; + /** + * add a remote to the GitRepo + */ + remoteAdd(remoteNameArg: string, remoteLinkArg: string) { + let done = q.defer() + if (!remoteNameArg) { + let err = new Error('smartgit.remote.add expects a valid remote name') + plugins.beautylog.error(err.message) + done.reject(err) + return done.promise + }; + if (!remoteLinkArg) { + let err = new Error() + plugins.beautylog.error(err.message) + done.reject(err) + return done.promise + }; + + // if everything is all right proceed + plugins.shelljs.exec(`cd ${this.repoBase} && git remote add ${remoteNameArg} ${remoteLinkArg}`) + done.resolve() + return done.promise + } + + /** + * list remotes for a Gip + */ + remoteList(dirPathArg) { + let done = q.defer() + let remotes = {} + plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`) + done.resolve(remotes) + return done.promise + }; + + /** + * remove remote + */ + remoteRemove(dirPathArg: string) { + let done = q.defer() + return done.promise + } + /** * commit all files that are currently staged */ @@ -41,6 +84,7 @@ export class GitRepo { return done.promise } + /** * pull latest changes from remote */ @@ -71,9 +115,21 @@ export class GitRepo { 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() plugins.smartfile.fs.ensureDir(toArg) @@ -83,6 +139,9 @@ export let createRepoFromClone = (fromArg: string, toArg: string) => { return done.promise } +/** + * creates a new GitRepo instance after initializing a new Git Repository + */ export let createRepoFromInit = (destinationDirArg: string) => { let done = q.defer() plugins.smartfile.fs.ensureDir(destinationDirArg) diff --git a/ts/smartgit.remote.ts b/ts/smartgit.remote.ts deleted file mode 100644 index c1d3533..0000000 --- a/ts/smartgit.remote.ts +++ /dev/null @@ -1,65 +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)){ - let err = new Error("smartgit.remote.add expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - return done.promise; - }; - 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 ${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)){ - let err = new Error("smartgit.remote.list expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - 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)){ - let err = new Error("smartgit.remote.remove expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - return done.promise; - }; - // if everything is all right -} - -export let remote = { - add: add, - list: list, - remove: remove -} \ No newline at end of file diff --git a/ts/smartgit.status.ts b/ts/smartgit.status.ts deleted file mode 100644 index fdedc3d..0000000 --- a/ts/smartgit.status.ts +++ /dev/null @@ -1,16 +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)){ - let err = new Error("smartgit.status expects a valid git directory"); - plugins.beautylog.error(err.message); - done.reject(err); - return done.promise; - }; - // if everything seems allright proceed - plugins.shelljs.exec(`(cd ${dirPathArg} && git status)`); - done.resolve(); - return done.promise; -}; \ No newline at end of file