fix(core): update

This commit is contained in:
Philipp Kunz 2019-06-18 15:17:50 +02:00
parent f72beabd90
commit e103074684
21 changed files with 2802 additions and 743 deletions

25
.gitignore vendored
View File

@ -1,13 +1,22 @@
node_modules/
test/temp/
test/temp2/
.nogit/
# artifacts
coverage/
public/
pages/
#npm debug
npm-debug.log
# installs
node_modules/
ts/*.js
ts/*.js.map
ts/typings/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@ -1,49 +1,117 @@
image: hosttoday/ht-docker-node:npmts
# gitzone ci_default
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- trigger
- metadata
before_script:
- npmci prepare ssh
testLEGACY:
stage: test
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
- npmci git mirror
tags:
- docker
allow_failure: true
- docker
- notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLTS:
stage: test
script:
- npmci test lts
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- docker
- notpriv
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

View File

@ -1,30 +1,28 @@
# smartgit
smart git wrapper for node.
# @pushrocks/smartgit
smart wrapper for nodegit
smartgit expects git to be installed on target machine.
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartgit)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartgit)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartgit)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartgit/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartgit)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartgit)
* [github.com (source mirror)](https://github.com/pushrocks/smartgit)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartgit/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartgit/badges/master/build.svg)](https://gitlab.com/pushrocks/smartgit/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartgit/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartgit/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartgit.svg)](https://david-dm.org/pushrocks/smartgit)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartgit/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartgit/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartgit/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartgit)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![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/)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartgit.svg)](https://www.npmjs.com/package/@pushrocks/smartgit)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartgit/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartgit)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
We recommend the use of TypeScript for best in class intellisense
```javascript
// import smartgit:
import { GitRepo } from 'smartgit'
import { GitRepo } from 'smartgit';
// Initialize smartgit:
// -- note: there are 3 ways to initialize smartgit
@ -33,36 +31,46 @@ import { GitRepo } from 'smartgit'
// -- -- 3. with a new Git repo
// -- 1. existing Git Repo:
let myExistingGitRepo = new GitRepo('/path/to/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
})
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
})
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')
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
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

12
dist/index.d.ts vendored
View File

@ -1,12 +0,0 @@
/// <reference types="q" />
import * as q from 'q';
import { GitRepo } from './smartgit.classes.gitrepo';
export { GitRepo };
/**
* creates a new GitRepo Instance after cloning a project
*/
export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise<GitRepo>;
/**
* creates a new GitRepo instance after initializing a new Git Repository
*/
export declare let createRepoFromInit: (destinationDirArg: string) => q.Promise<GitRepo>;

28
dist/index.js vendored
View File

@ -1,28 +0,0 @@
"use strict";
const q = require("q");
const plugins = require("./smartgit.plugins");
const smartgit_classes_gitrepo_1 = require("./smartgit.classes.gitrepo");
exports.GitRepo = smartgit_classes_gitrepo_1.GitRepo;
/**
* creates a new GitRepo Instance after cloning a project
*/
exports.createRepoFromClone = (fromArg, toArg) => {
let done = q.defer();
plugins.smartfile.fs.ensureDir(toArg);
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
let newRepo = new smartgit_classes_gitrepo_1.GitRepo(toArg);
done.resolve(newRepo);
return done.promise;
};
/**
* creates a new GitRepo instance after initializing a new Git Repository
*/
exports.createRepoFromInit = (destinationDirArg) => {
let done = q.defer();
plugins.smartfile.fs.ensureDir(destinationDirArg);
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`);
let newRepo = new smartgit_classes_gitrepo_1.GitRepo(destinationDirArg);
done.resolve(newRepo);
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDhDQUErQztBQUUvQyx5RUFBb0Q7QUFFaEQscURBQU87QUFHWDs7R0FFRztBQUNRLFFBQUEsbUJBQW1CLEdBQUcsQ0FBQyxPQUFlLEVBQUUsS0FBYTtJQUM1RCxJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFXLENBQUE7SUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ3JDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGFBQWEsT0FBTyxJQUFJLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDckQsSUFBSSxPQUFPLEdBQUcsSUFBSSxrQ0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2hDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLGtCQUFrQixHQUFHLENBQUMsaUJBQXlCO0lBQ3RELElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQVcsQ0FBQTtJQUM3QixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUNqRCxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLGlCQUFpQixjQUFjLENBQUMsQ0FBQTtJQUMzRCxJQUFJLE9BQU8sR0FBRyxJQUFJLGtDQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUM1QyxJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9

View File

@ -1,58 +0,0 @@
/// <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;

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
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');

View File

@ -1,9 +0,0 @@
"use strict";
require("typings-global");
exports.path = require("path");
exports.beautylog = require("beautylog");
exports.shelljs = require("shelljs");
exports.smartfile = require("smartfile");
exports.smartpath = require("smartpath");
exports.smartstring = require("smartstring");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHFDQUEwQztBQUMxQyx5Q0FBOEM7QUFDOUMseUNBQThDO0FBQzlDLDZDQUFrRCJ9

View File

@ -1,12 +1,22 @@
{
"npmts": {
"mode": "default",
"codecov": true,
"coverageTreshold": 71
},
"npmci": {
"globalNpmTools": [
"npmts"
]
"npmts": {
"mode": "default",
"codecov": true,
"coverageTreshold": 71
},
"npmci": {
"globalNpmTools": [
"npmts"
]
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartgit",
"shortDescription": "smart wrapper for nodegit",
"npmPackagename": "@pushrocks/smartgit",
"license": "MIT"
}
}
}

2535
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{
"name": "smartgit",
"name": "@pushrocks/smartgit",
"version": "1.0.5",
"description": "smart git wrapper for node",
"description": "smart wrapper for nodegit",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"cleanTest": "rm -rf test/temp*",
"test": "(npm run cleanTest && npmts)"
"test": "(tstest test/)",
"build": "(tsbuild)"
},
"repository": {
"type": "git",
@ -24,21 +24,31 @@
},
"homepage": "https://gitlab.com/pushrocks/smartgit",
"dependencies": {
"@types/minimatch": "*",
"@types/shelljs": "^0.3.32",
"beautylog": "^6.0.0",
"q": "^1.4.1",
"shelljs": "^0.7.5",
"simple-git": "^1.62.0",
"smartfile": "^4.1.0",
"smartpath": "^3.2.5",
"smartstring": "^2.0.22",
"typings-global": "^1.0.14"
"@pushrocks/smartfile": "^7.0.2",
"@pushrocks/smartpath": "^4.0.1",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartshell": "^2.0.23",
"@pushrocks/smartstring": "^3.0.10",
"@types/minimatch": "^3.0.3",
"@types/nodegit": "^0.24.8",
"nodegit": "^0.24.3"
},
"devDependencies": {
"@types/should": "^8.1.30",
"npmts-g": "^5.2.8",
"should": "^11.1.1",
"typings-test": "^1.0.3"
}
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.9",
"tslint": "^5.17.0",
"tslint-config-prettier": "^1.18.0"
},
"private": false,
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

@ -1 +0,0 @@
Subproject commit a261a2ea02b39d8ff8c66b078a894a75a0d4f457

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,110 +0,0 @@
"use strict";
require("typings-test");
let shelljs = require('shelljs');
const path = require("path");
const should = require("should");
const smartgit = require("../dist/index");
let paths = {
temp1: path.resolve('./test/temp/'),
temp2: path.resolve('./test/temp2/'),
temp3: path.resolve('./test/temp3'),
temp4: path.resolve('./test/temp4'),
noGit: path.resolve('./test/')
};
describe('smartgit', function () {
let testGitRepo;
let testGitRepoCloned;
let testGitRepoInit;
describe('instance', function () {
it('should error for invalid path', function (done) {
try {
testGitRepo = new smartgit.GitRepo(paths.temp1);
}
catch (err) {
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo);
done();
}
});
it('should init a new repo', function (done) {
this.timeout(40000);
smartgit.createRepoFromInit(paths.temp1)
.then((gitRepo) => {
should(gitRepo).be.instanceOf(smartgit.GitRepo);
done();
}).catch(err => {
throw err;
});
});
it('should create am instance for an existing repo', function () {
testGitRepo = new smartgit.GitRepo(paths.temp1);
should(testGitRepo).be.instanceOf(smartgit.GitRepo);
});
it('should clone a repository using ssh and sshkey', function (done) {
this.timeout(40000);
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp2)
.then((gitRepo) => {
should(gitRepo).be.instanceOf(smartgit.GitRepo);
done();
}).catch(err => {
throw err;
});
});
it('should clone a repository using https', function (done) {
this.timeout(40000);
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp3)
.then((gitRepo) => {
should(gitRepo).be.instanceOf(smartgit.GitRepo);
done();
}).catch(err => {
throw err;
});
});
});
describe('.add', function () {
it('should add a file to an existing repository', function () {
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`);
testGitRepo.addAll();
});
});
describe('.check()', function () {
it('should check a git repo', function () {
let checkResult = testGitRepo.check();
should(checkResult).be.true();
});
});
describe('commit', function () {
it('should commit a new file to an existing repository', function () {
testGitRepo.commit('added a new file');
});
});
describe('pull', function () {
this.timeout(40000);
it('should pull from origin', function (done) {
testGitRepo.pull()
.then(() => {
done();
});
});
});
describe('push', function () {
this.timeout(40000);
it('should push to origin', function (done) {
testGitRepo.push('origin', 'master')
.then(() => {
done();
});
});
});
describe('remote', function () {
it('should add a remote', function () {
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo');
});
it('should', function (done) {
testGitRepo.remoteList()
.then(() => {
done();
});
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiX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ElB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,EAAC;IAEhB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -1,110 +1,4 @@
import 'typings-test'
import beautylog = require('beautylog')
let shelljs = require('shelljs')
import path = require('path')
import * as should from 'should'
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartgit from '../ts/index';
import smartgit = require('../dist/index')
let paths = {
temp1: path.resolve('./test/temp/'),
temp2: path.resolve('./test/temp2/'),
temp3: path.resolve('./test/temp3'),
temp4: path.resolve('./test/temp4'),
noGit: path.resolve('./test/')
}
describe('smartgit', function () {
let testGitRepo: smartgit.GitRepo
let testGitRepoCloned: smartgit.GitRepo
let testGitRepoInit: smartgit.GitRepo
describe('instance', function () {
it('should error for invalid path', function (done) {
try {
testGitRepo = new smartgit.GitRepo(paths.temp1)
} catch (err) {
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo)
done()
}
})
it('should init a new repo', function (done) {
this.timeout(40000)
smartgit.createRepoFromInit(paths.temp1)
.then((gitRepo) => {
should(gitRepo).be.instanceOf(smartgit.GitRepo)
done()
}).catch(err => {
throw err
})
})
it('should create am instance for an existing repo', function () {
testGitRepo = new smartgit.GitRepo(paths.temp1)
should(testGitRepo).be.instanceOf(smartgit.GitRepo)
})
it('should clone a repository using ssh and sshkey', function (done) {
this.timeout(40000)
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp2)
.then((gitRepo) => {
should(gitRepo).be.instanceOf(smartgit.GitRepo)
done()
}).catch(err => {
throw err
})
})
it('should clone a repository using https', function (done) {
this.timeout(40000)
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp3)
.then((gitRepo) => {
should(gitRepo).be.instanceOf(smartgit.GitRepo)
done()
}).catch(err => {
throw err
})
})
})
describe('.add', function () {
it('should add a file to an existing repository', function () {
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`)
testGitRepo.addAll()
})
})
describe('.check()', function() {
it('should check a git repo', function() {
let checkResult = testGitRepo.check()
should(checkResult).be.true()
})
})
describe('commit', function () {
it('should commit a new file to an existing repository', function () {
testGitRepo.commit('added a new file')
})
})
describe('pull', function () {
this.timeout(40000)
it('should pull from origin', function (done) {
testGitRepo.pull()
.then(() => {
done()
})
})
})
describe('push', function () {
this.timeout(40000)
it('should push to origin', function (done) {
testGitRepo.push('origin', 'master')
.then(() => {
done()
})
})
})
describe('remote', function () {
it('should add a remote', function () {
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo')
})
it('should', function(done) {
testGitRepo.remoteList()
.then(() => {
done()
})
})
})
})
tap.start();

View File

@ -1,31 +1,28 @@
import * as q from 'q'
import plugins = require("./smartgit.plugins");
import plugins = require('./smartgit.plugins');
import { GitRepo } from './smartgit.classes.gitrepo'
export {
GitRepo
}
import { GitRepo } from './smartgit.classes.gitrepo';
export { GitRepo };
/**
* creates a new GitRepo Instance after cloning a project
*/
export let createRepoFromClone = (fromArg: string, toArg: string) => {
let done = q.defer<GitRepo>()
plugins.smartfile.fs.ensureDir(toArg)
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`)
let newRepo = new GitRepo(toArg)
done.resolve(newRepo)
return done.promise
}
export const createRepoFromClone = async (fromArg: string, toArg: string): Promise<GitRepo> => {
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
}
export const createRepoFromInit = async (destinationDirArg: string): Promise<GitRepo> => {
const 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;
};

View File

@ -1,150 +1,24 @@
import * as q from 'q'
import * as plugins from './smartgit.plugins'
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')
}
}
// STATIC
/**
* creates a new GitRepo Instance after cloning a project
*/
public static async createRepoFromClone(fromArg: string, toArg: string): Promise<GitRepo> {
return new GitRepo();
}
/**
* checks if the Repo is valid
*/
check(): boolean {
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
}
/**
* creates a new GitRepo instance after initializing a new Git Repository
*/
public static async createRepoFromInit(destinationDirArg: string): Promise<GitRepo> {
return new GitRepo();
}
/**
* 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)
// INSTANCE
nodegitRepo;
}

View File

@ -1,7 +1,16 @@
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')
// node native
import * as path from 'path';
export { path };
import * as smartfile from '@pushrocks/smartfile';
import * as smartpath from '@pushrocks/smartpath';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartstring from '@pushrocks/smartstring';
export { smartfile, smartpath, smartpromise, smartstring };
// third party
import * as nodegit from 'nodegit';
export { nodegit };

View File

@ -1,3 +1,17 @@
{
"extends": "tslint-config-standard"
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}