Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
98d1f8aea2 | |||
1f542367e6 | |||
201a5014ed | |||
6cc245ae7e | |||
1377fb6eb7 | |||
daf8c80513 | |||
46fce49356 | |||
8616613a95 | |||
352e4d8e96 | |||
c2105ce78f | |||
2864fc5507 | |||
fea523ff5c | |||
872f2354c5 | |||
ff0318534f | |||
e103074684 | |||
f72beabd90 | |||
958a625633 | |||
871fd55c5c | |||
07fd9b9fa7 | |||
62d6a8d685 | |||
047cf02e6a | |||
69127cacdd | |||
7529098a50 | |||
15c331690b |
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,13 +1,22 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
test/temp/
|
|
||||||
test/temp2/
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
#npm debug
|
# installs
|
||||||
npm-debug.log
|
node_modules/
|
||||||
|
|
||||||
ts/*.js
|
# caches
|
||||||
ts/*.js.map
|
.yarn/
|
||||||
ts/typings/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
106
.gitlab-ci.yml
106
.gitlab-ci.yml
@ -1,49 +1,105 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
|
|
||||||
before_script:
|
# ====================
|
||||||
- npmci prepare ssh
|
# security stage
|
||||||
|
# ====================
|
||||||
testLEGACY:
|
mirror:
|
||||||
stage: test
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
- 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:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install lts
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- 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:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
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:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
19
.travis.yml
19
.travis.yml
@ -1,19 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- 4
|
|
||||||
- stable
|
|
||||||
before_install:
|
|
||||||
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
|
||||||
- sudo apt-get update
|
|
||||||
- sudo apt-get install libstdc++-4.9-dev -y
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@lossless.digital
|
|
||||||
api_key:
|
|
||||||
secure: o/3H4keWRAvHZaJnUN9UX+hqu+prKGtBsOEWVIaRXUpf6nIHIDm9zlJrS5cv2VUseOZqLAOkzeGYPqlOJlxccy5frKEYMhtCY97BjKvUOf01roL82OGiahw5Bv04NcaBoSepCliyyXihlgZO/5tSoR1seY4ycul2qWLktaEmh8HcTPjem8gB49Svpfk8yPKLpq6cv/sSakt2X24Cq+vfdxYiz7GcgBfv3EVAndUmQ9KMQfkSbq8XgYEZKrLi5kdpXX0y1LRdsbn2rwuMwLOmefCenmQSuBCbYmbOxPgVHHHjVm9To/rhx8YHBCcZSH9go2pdDLwrd7VPOCK+vMHCz/rlASwVM/BGr+aJHCFLAyovrIU7cvbbjLPOUjto6xY2XckMmDBD1YDxYnAJAON1QrdXE9hVVRfMNfaC2leFAwhla1WMok5DcEv+/Q9cUXQCBGQHtBhkhmCCt54ERLFnjXCDZr1icR/0lhtQY54hin5jSHqnU2hTZtTpQX7sF0yZM2sbhTBpV5FTDAGH/ohNWSEnTwAXmL9iwZCTvtWUbBeOUSDRj8BLS54uiaIcIVytNY0p2PdnhwJAWO+4FGjSOT+RuK8RiKzyVXjPiX8TCzaOqBFs947m8SSNMSt6zyqOI27gOSzU7szgsKY769Fl+X9sdzFXaSa72rj4EdvgiBA=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/smartgit
|
|
||||||
notifications:
|
|
||||||
slack:
|
|
||||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 Push.Rocks
|
Copyright (c) 2015 Lossless GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
80
README.md
80
README.md
@ -1,30 +1,28 @@
|
|||||||
# smartgit
|
# @pushrocks/smartgit
|
||||||
smart git wrapper for node.
|
smart wrapper for nodegit
|
||||||
|
|
||||||
smartgit expects git to be installed on target machine.
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartgit)
|
||||||
## Availabililty
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartgit)
|
||||||
[](https://www.npmjs.com/package/smartgit)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartgit)
|
||||||
[](https://gitlab.com/pushrocks/smartgit)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartgit/)
|
||||||
[](https://github.com/pushrocks/smartgit)
|
|
||||||
[](https://pushrocks.gitlab.io/smartgit/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||||
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||||
[](https://david-dm.org/pushrocks/smartgit)
|
[](https://www.npmjs.com/package/@pushrocks/smartgit)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartgit/master/dependencies/npm)
|
[](https://snyk.io/test/npm/@pushrocks/smartgit)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartgit)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://prettier.io/)
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
We recommend the use of TypeScript for best in class intellisense
|
We recommend the use of TypeScript for best in class intellisense
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// import smartgit:
|
// import smartgit:
|
||||||
import { GitRepo } from 'smartgit'
|
import { GitRepo } from 'smartgit';
|
||||||
|
|
||||||
// Initialize smartgit:
|
// Initialize smartgit:
|
||||||
// -- note: there are 3 ways to initialize smartgit
|
// -- note: there are 3 ways to initialize smartgit
|
||||||
@ -33,36 +31,46 @@ import { GitRepo } from 'smartgit'
|
|||||||
// -- -- 3. with a new Git repo
|
// -- -- 3. with a new Git repo
|
||||||
|
|
||||||
// -- 1. existing 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:
|
// -- 2. cloned Git Repo:
|
||||||
let myClonedGitRepo: GitRepo
|
let myClonedGitRepo: GitRepo;
|
||||||
smartgit.createRepoFromClone('git@github.com:username/reponame.git')
|
smartgit.createRepoFromClone('git@github.com:username/reponame.git').then(gitRepo => {
|
||||||
.then(gitRepo => { // non blocking
|
// non blocking
|
||||||
myClonedGitRepo = gitRepo
|
myClonedGitRepo = gitRepo;
|
||||||
})
|
});
|
||||||
|
|
||||||
// -- 3. new Git Repo
|
// -- 3. new Git Repo
|
||||||
let myNewGitRepo: GitRepo
|
let myNewGitRepo: GitRepo;
|
||||||
smartgit.createRepoFromInit('/path/to/new/folder') // smartgit will create any new folder, be careful
|
smartgit
|
||||||
.then(gitRepo => { // non blocking
|
.createRepoFromInit('/path/to/new/folder') // smartgit will create any new folder, be careful
|
||||||
myNewGitRepo = gitRepo
|
.then(gitRepo => {
|
||||||
})
|
// non blocking
|
||||||
|
myNewGitRepo = gitRepo;
|
||||||
|
});
|
||||||
|
|
||||||
// Using smartgit instance
|
// Using smartgit instance
|
||||||
// -- most used actions
|
// -- most used actions
|
||||||
// -- all actions return promises, so make sure to use promise chaining for any dependent tasks
|
// -- all actions return promises, so make sure to use promise chaining for any dependent tasks
|
||||||
myExistingGitRepo.addAll() // returns promise, stages all changed files
|
myExistingGitRepo.addAll(); // returns promise, stages all changed files
|
||||||
myExistingGitRepo.add(['relative/path/to/file.txt','another/file2.txt']) // returns promise, stages specific 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.commit('my commit message'); // returns promise, commits staged files
|
||||||
myExistingGitRepo.status() // returns promise
|
myExistingGitRepo
|
||||||
.then(status => { // Use TypeScript for status type information
|
.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.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
|
Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment
|
||||||
|
|
||||||
[](https://push.rocks)
|
[](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)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
12
dist/index.d.ts
vendored
12
dist/index.d.ts
vendored
@ -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) => void;
|
|
27
dist/index.js
vendored
27
dist/index.js
vendored
@ -1,27 +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);
|
|
||||||
};
|
|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QkFBaUIsQ0FBQyxDQUFBO0lBQzVDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7QUFDekIsQ0FBQyxDQUFBIn0=
|
|
57
dist/smartgit.classes.gitrepo.d.ts
vendored
57
dist/smartgit.classes.gitrepo.d.ts
vendored
@ -1,57 +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
|
|
||||||
*/
|
|
||||||
addAll(dirPathArg: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* add a remote to the GitRepo
|
|
||||||
*/
|
|
||||||
remoteAdd(remoteNameArg: string, remoteLinkArg: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* list remotes for a Gip
|
|
||||||
*/
|
|
||||||
remoteList(dirPathArg: any): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* remove remote
|
|
||||||
*/
|
|
||||||
remoteRemove(dirPathArg: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* commit all files that are currently staged
|
|
||||||
*/
|
|
||||||
commit(commitMessage: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* pull latest changes from remote
|
|
||||||
*/
|
|
||||||
pull(sourceArg?: string, branchArg?: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* push new commits to remote
|
|
||||||
*/
|
|
||||||
push(remoteNameArg?: string, remoteBranchArg?: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* sync
|
|
||||||
*/
|
|
||||||
sync(): void;
|
|
||||||
/**
|
|
||||||
* get the current status
|
|
||||||
*/
|
|
||||||
status(): q.Promise<{}>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* creates a new GitRepo Instance after cloning a project
|
|
||||||
*/
|
|
||||||
export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise<GitRepo>;
|
|
||||||
/**
|
|
||||||
* creates a new GitRepo instance after initializing a new Git Repository
|
|
||||||
*/
|
|
||||||
export declare let createRepoFromInit: (destinationDirArg: string) => void;
|
|
143
dist/smartgit.classes.gitrepo.js
vendored
143
dist/smartgit.classes.gitrepo.js
vendored
File diff suppressed because one or more lines are too long
7
dist/smartgit.plugins.d.ts
vendored
7
dist/smartgit.plugins.d.ts
vendored
@ -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');
|
|
9
dist/smartgit.plugins.js
vendored
9
dist/smartgit.plugins.js
vendored
@ -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
|
|
90
index.js
90
index.js
@ -1,90 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartgitPlugins;
|
|
||||||
(function (SmartgitPlugins) {
|
|
||||||
SmartgitPlugins.init = function () {
|
|
||||||
var plugins = {
|
|
||||||
path: require("path"),
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
nodegit: require("nodegit"),
|
|
||||||
Q: require("q")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
};
|
|
||||||
})(SmartgitPlugins || (SmartgitPlugins = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartgitClone;
|
|
||||||
(function (SmartgitClone) {
|
|
||||||
function init() {
|
|
||||||
var clone = function (options) {
|
|
||||||
/***** URL Checks ******/
|
|
||||||
if (options.from == "undefined" || options.to == "undefined") {
|
|
||||||
plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/***** Path Checks ******/
|
|
||||||
if (!/^\/.*/.test(options.to)) {
|
|
||||||
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
plugins.beautylog.log("Now cloning " + options.from);
|
|
||||||
var cloneOptions = {};
|
|
||||||
var cloneRepository = plugins.nodegit.Clone(options.from, options.to, cloneOptions);
|
|
||||||
smartgit.check(cloneRepository);
|
|
||||||
};
|
|
||||||
return clone;
|
|
||||||
}
|
|
||||||
SmartgitClone.init = init;
|
|
||||||
})(SmartgitClone || (SmartgitClone = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartgitInit;
|
|
||||||
(function (SmartgitInit) {
|
|
||||||
SmartgitInit.init = function () {
|
|
||||||
var gitinit = function (dest) {
|
|
||||||
if (dest === void 0) { dest = "undefined"; }
|
|
||||||
if (dest == "undefined") {
|
|
||||||
return; // ...and return function here if not
|
|
||||||
}
|
|
||||||
var isBare = 0; //lets create a subfolder
|
|
||||||
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
|
|
||||||
// do something with repo here.
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return gitinit;
|
|
||||||
};
|
|
||||||
})(SmartgitInit || (SmartgitInit = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartgitCommit;
|
|
||||||
(function (SmartgitCommit) {
|
|
||||||
SmartgitCommit.init = function () {
|
|
||||||
var commit = function (pathArg, commitMessage) {
|
|
||||||
var result = plugins.nodegit.index.addByPath(pathArg);
|
|
||||||
if (result == 0) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return commit;
|
|
||||||
};
|
|
||||||
})(SmartgitCommit || (SmartgitCommit = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var SmartgitCheck;
|
|
||||||
(function (SmartgitCheck) {
|
|
||||||
SmartgitCheck.init = function () {
|
|
||||||
var check = function () {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
return check;
|
|
||||||
};
|
|
||||||
})(SmartgitCheck || (SmartgitCheck = {}));
|
|
||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
/// <reference path="smartgit.plugins.ts" />
|
|
||||||
/// <reference path="smartgit.clone.ts" />
|
|
||||||
/// <reference path="smartgit.init.ts" />
|
|
||||||
/// <reference path="smartgit.commit.ts" />
|
|
||||||
/// <reference path="smartgit.check.ts" />
|
|
||||||
var plugins = SmartgitPlugins.init();
|
|
||||||
//Build the smartgit object
|
|
||||||
var smartgit = {};
|
|
||||||
smartgit.clone = SmartgitClone.init();
|
|
||||||
smartgit.commit = SmartgitCommit.init();
|
|
||||||
smartgit.check = SmartgitCheck.init();
|
|
||||||
smartgit.init = SmartgitInit.init();
|
|
||||||
module.exports = smartgit;
|
|
22
npmextra.json
Normal file
22
npmextra.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"npmts": {
|
||||||
|
"mode": "default",
|
||||||
|
"codecov": true,
|
||||||
|
"coverageTreshold": 71
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartgit",
|
||||||
|
"shortDescription": "smart wrapper for nodegit",
|
||||||
|
"npmPackagename": "@pushrocks/smartgit",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"mode":"default",
|
|
||||||
"codecov":true,
|
|
||||||
"coverageTreshold":71
|
|
||||||
}
|
|
2490
package-lock.json
generated
Normal file
2490
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@ -1,13 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "smartgit",
|
"name": "@pushrocks/smartgit",
|
||||||
"version": "1.0.1",
|
"version": "1.0.13",
|
||||||
"description": "smart git wrapper for node",
|
"description": "smart wrapper for nodegit",
|
||||||
"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*",
|
"test": "(tstest test/)",
|
||||||
"test": "(npm run cleanTest && npmts)",
|
"build": "(tsbuild)"
|
||||||
"install": "node dist/postinstall.js"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -25,21 +24,31 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/minimatch": "*",
|
"@pushrocks/smartfile": "^7.0.4",
|
||||||
"@types/shelljs": "^0.3.32",
|
"@pushrocks/smartpath": "^4.0.1",
|
||||||
"beautylog": "^6.0.0",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"q": "^1.4.1",
|
"@pushrocks/smartshell": "^2.0.23",
|
||||||
"shelljs": "^0.7.5",
|
"@pushrocks/smartstring": "^3.0.10",
|
||||||
"simple-git": "^1.62.0",
|
"@types/minimatch": "^3.0.3",
|
||||||
"smartfile": "^4.1.0",
|
"@types/nodegit": "^0.24.10",
|
||||||
"smartpath": "^3.2.5",
|
"nodegit": "^0.25.1"
|
||||||
"smartstring": "^2.0.22",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"npmts-g": "^5.2.8",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"should": "^11.1.1",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"typings-test": "^1.0.3"
|
"tslint": "^5.19.0",
|
||||||
}
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
9
test.js
9
test.js
@ -1,9 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var smartgit = require("./index.js");
|
|
||||||
var beautylog = require("beautylog");
|
|
||||||
var path = require("path");
|
|
||||||
smartgit.clone({
|
|
||||||
from: "https://github.com/pushrocks/docs.git",
|
|
||||||
to: path.resolve("./test/temp/")
|
|
||||||
});
|
|
||||||
beautylog.success("Test successfull");
|
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
79
test/test.js
79
test/test.js
@ -1,79 +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 = {
|
|
||||||
temp: path.resolve('./test/temp/'),
|
|
||||||
temp2: path.resolve('./test/temp2/'),
|
|
||||||
temp3: path.resolve('./test/temp3'),
|
|
||||||
temp4: path.resolve('./test/temp4'),
|
|
||||||
noGit: path.resolve('./test/')
|
|
||||||
};
|
|
||||||
describe('smartgit', function () {
|
|
||||||
let testGitRepo;
|
|
||||||
let testGitRepoCloned;
|
|
||||||
let testGitRepoInit;
|
|
||||||
describe('instance', function () {
|
|
||||||
it('should create a valid new instance from path', function () {
|
|
||||||
testGitRepo = new smartgit.GitRepo('path.temp');
|
|
||||||
should(testGitRepo).be.instanceOf(smartgit.GitRepo);
|
|
||||||
});
|
|
||||||
it('should clone a repository using ssh and sshkey', function (done) {
|
|
||||||
this.timeout(40000);
|
|
||||||
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp)
|
|
||||||
.then((gitRepo) => {
|
|
||||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
|
||||||
done();
|
|
||||||
}).catch(err => {
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should clone a repository using https', function (done) {
|
|
||||||
this.timeout(40000);
|
|
||||||
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp2)
|
|
||||||
.then((gitRepo) => {
|
|
||||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
|
||||||
done();
|
|
||||||
}).catch(err => {
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('.add', function () {
|
|
||||||
it('should add a file to an existing repository', function () {
|
|
||||||
shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`);
|
|
||||||
testGitRepo.addAll(paths.temp);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('commit', function () {
|
|
||||||
it('should commit a new file to an existing repository', function () {
|
|
||||||
testGitRepo.commit('added a new file');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('pull', function () {
|
|
||||||
this.timeout(40000);
|
|
||||||
it('should pull from origin', function (done) {
|
|
||||||
testGitRepo.pull()
|
|
||||||
.then(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('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');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQixJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUE7QUFDaEMsNkJBQTZCO0FBQzdCLGlDQUFnQztBQUVoQywwQ0FBMEM7QUFDMUMsSUFBSSxLQUFLLEdBQUc7SUFDUixJQUFJLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUM7SUFDbEMsS0FBSyxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsZUFBZSxDQUFDO0lBQ3BDLEtBQUssRUFBRSxJQUFJLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQztJQUNuQyxLQUFLLEVBQUUsSUFBSSxD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AQ,CAAC,QAAQ,EAAC;QACd,EAAE,CAAC,2BAA2B,EAAC,UAAS,IAAI;YACxC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpB,QAAQ,CAAC,KAAK,CAAC;gBACX,IAAI,EAAC,uCAAuC;gBAC5C,EAAE,EAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;aAClC,CAAC,CAAC,IAAI,CAAC;gBACJ,IAAI,EAAE,CAAC;YACX,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,QAAQ,EAAC;IAElB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,QAAQ,EAAC;IAElB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,EAAC;IAEhB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
86
test/test.ts
86
test/test.ts
@ -1,80 +1,12 @@
|
|||||||
import 'typings-test'
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import beautylog = require('beautylog')
|
import * as smartgit from '../ts/index';
|
||||||
let shelljs = require('shelljs')
|
|
||||||
import path = require('path')
|
|
||||||
import * as should from 'should'
|
|
||||||
|
|
||||||
import smartgit = require('../dist/index')
|
import * as path from 'path';
|
||||||
let paths = {
|
|
||||||
temp: path.resolve('./test/temp/'),
|
|
||||||
temp2: path.resolve('./test/temp2/'),
|
|
||||||
temp3: path.resolve('./test/temp3'),
|
|
||||||
temp4: path.resolve('./test/temp4'),
|
|
||||||
noGit: path.resolve('./test/')
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('smartgit', function () {
|
const testRepoDir = path.join(__dirname, '../.nogit/testrepo');
|
||||||
let testGitRepo: smartgit.GitRepo
|
|
||||||
let testGitRepoCloned: smartgit.GitRepo
|
tap.test('should create a new repo at .nogit', async () => {
|
||||||
let testGitRepoInit: smartgit.GitRepo
|
const gitRepo = await smartgit.GitRepo.fromCreatingRepoInDir(testRepoDir);
|
||||||
describe('instance', function () {
|
|
||||||
it('should create a valid new instance from path', function () {
|
|
||||||
testGitRepo = new smartgit.GitRepo('path.temp')
|
|
||||||
should(testGitRepo).be.instanceOf(smartgit.GitRepo)
|
|
||||||
})
|
|
||||||
it('should clone a repository using ssh and sshkey', function (done) {
|
|
||||||
this.timeout(40000)
|
|
||||||
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp)
|
|
||||||
.then((gitRepo) => {
|
|
||||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
|
||||||
done()
|
|
||||||
}).catch(err => {
|
|
||||||
throw err
|
|
||||||
})
|
|
||||||
})
|
|
||||||
it('should clone a repository using https', function (done) {
|
|
||||||
this.timeout(40000)
|
|
||||||
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp2)
|
|
||||||
.then((gitRepo) => {
|
|
||||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
|
||||||
done()
|
|
||||||
}).catch(err => {
|
|
||||||
throw err
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('.add', function () {
|
|
||||||
it('should add a file to an existing repository', function () {
|
|
||||||
shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`)
|
|
||||||
testGitRepo.addAll(paths.temp)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('commit', function () {
|
|
||||||
it('should commit a new file to an existing repository', function () {
|
|
||||||
testGitRepo.commit('added a new file')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('pull', function () {
|
|
||||||
this.timeout(40000)
|
|
||||||
it('should pull from origin', function (done) {
|
|
||||||
testGitRepo.pull()
|
|
||||||
.then(() => {
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('push', function () {
|
|
||||||
this.timeout(40000)
|
|
||||||
it('should push to origin', function (done) {
|
|
||||||
testGitRepo.push('origin', 'master')
|
|
||||||
.then(() => {
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('remote', function () {
|
|
||||||
it('should add a remote', function () {
|
|
||||||
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
31
ts/index.ts
31
ts/index.ts
@ -1,30 +1,3 @@
|
|||||||
import * as q from 'q'
|
import plugins = require('./smartgit.plugins');
|
||||||
import plugins = require("./smartgit.plugins");
|
|
||||||
|
|
||||||
import { GitRepo } from './smartgit.classes.gitrepo'
|
export * 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
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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,151 +1,79 @@
|
|||||||
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
|
* class GitRepo allows access to git directories from node
|
||||||
*/
|
*/
|
||||||
export class GitRepo {
|
export class GitRepo {
|
||||||
repoBase: string
|
// STATIC
|
||||||
constructor(repoBaseArg: string) {
|
/**
|
||||||
this.repoBase = repoBaseArg
|
* creates a new GitRepo Instance after cloning a project
|
||||||
|
*/
|
||||||
|
public static async fromCloningIntoDir(fromArg: string, toArg: string): Promise<GitRepo> {
|
||||||
|
const dirArg = plugins.path.resolve(toArg);
|
||||||
|
const ngRespository = await plugins.nodegit.Clone.clone(fromArg, toArg, {
|
||||||
|
bare: 0,
|
||||||
|
checkoutBranch: 'master'
|
||||||
|
});
|
||||||
|
return new GitRepo(ngRespository);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async fromCreatingRepoInDir(dirArg: string): Promise<GitRepo> {
|
||||||
|
dirArg = plugins.path.resolve(dirArg);
|
||||||
|
const ngRepository = await plugins.nodegit.Repository.init(dirArg, 0);
|
||||||
|
return new GitRepo(ngRepository);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async fromOpeningRepoDir(dirArg: string) {
|
||||||
|
dirArg = plugins.path.resolve(dirArg);
|
||||||
|
const ngRepository = await plugins.nodegit.Repository.open(dirArg);
|
||||||
|
return new GitRepo(ngRepository);
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public nodegitRepo: plugins.nodegit.Repository;
|
||||||
|
|
||||||
|
constructor(nodegitRepoArg: plugins.nodegit.Repository) {
|
||||||
|
this.nodegitRepo = nodegitRepoArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists remotes
|
||||||
|
*/
|
||||||
|
public async listRemotes(): Promise<string[]> {
|
||||||
|
return this.nodegitRepo.getRemotes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ensures the existance of a remote within a repository
|
||||||
|
* @param remoteNameArg
|
||||||
|
* @param remoteUrlArg
|
||||||
|
*/
|
||||||
|
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
|
||||||
|
const existingUrl = await this.getUrlForRemote(remoteNameArg);
|
||||||
|
if (existingUrl === remoteUrlArg) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (existingUrl) {
|
||||||
/**
|
await plugins.nodegit.Remote.delete(this.nodegitRepo, remoteNameArg);
|
||||||
* checks if the Repo is valid
|
|
||||||
*/
|
|
||||||
check(): boolean {
|
|
||||||
try {
|
|
||||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
|
|
||||||
} catch (err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
await plugins.nodegit.Remote.create(this.nodegitRepo, remoteNameArg, remoteUrlArg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stage all files in working directory
|
* gets the url for a specific remote
|
||||||
*/
|
*/
|
||||||
addAll(dirPathArg: string) {
|
public async getUrlForRemote(remoteName: string): Promise<string> {
|
||||||
let done = q.defer()
|
const ngRemote = await this.nodegitRepo.getRemote(remoteName);
|
||||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`)
|
if (ngRemote) {
|
||||||
done.resolve(dirPathArg)
|
return ngRemote.url();
|
||||||
return done.promise
|
} else {
|
||||||
};
|
return null;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public async pushBranchToRemote(branchName: string, remoteName: string) {
|
||||||
* list remotes for a Gip
|
await this.nodegitRepo.checkoutBranch(branchName);
|
||||||
*/
|
const ngRemote = await this.nodegitRepo.getRemote(remoteName);
|
||||||
remoteList(dirPathArg) {
|
ngRemote.push([branchName]);
|
||||||
let done = q.defer()
|
}
|
||||||
let remotes = {}
|
|
||||||
plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`)
|
|
||||||
done.resolve(remotes)
|
|
||||||
return done.promise
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* remove remote
|
|
||||||
*/
|
|
||||||
remoteRemove(dirPathArg: string) {
|
|
||||||
let done = q.defer()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* commit all files that are currently staged
|
|
||||||
*/
|
|
||||||
commit(commitMessage: string) {
|
|
||||||
let done = q.defer()
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git commit -m "${commitMessage}")`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pull latest changes from remote
|
|
||||||
*/
|
|
||||||
pull(sourceArg: string = '', branchArg: string = '') {
|
|
||||||
let done = q.defer()
|
|
||||||
// if everything is allright proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git pull ${sourceArg} ${branchArg})`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* push new commits to remote
|
|
||||||
*/
|
|
||||||
push(remoteNameArg: string = '', remoteBranchArg: string = '') {
|
|
||||||
let done = q.defer()
|
|
||||||
// if everything seems allright proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git push ${remoteNameArg} ${remoteBranchArg})`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sync
|
|
||||||
*/
|
|
||||||
sync() {
|
|
||||||
this.pull().then(() => {
|
|
||||||
this.push()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the current status
|
|
||||||
*/
|
|
||||||
status() {
|
|
||||||
let done = q.defer()
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git status)`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a new GitRepo Instance after cloning a project
|
|
||||||
*/
|
|
||||||
export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
|
||||||
let done = q.defer<GitRepo>()
|
|
||||||
plugins.smartfile.fs.ensureDir(toArg)
|
|
||||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`)
|
|
||||||
let newRepo = new GitRepo(toArg)
|
|
||||||
done.resolve(newRepo)
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a new GitRepo instance after initializing a new Git Repository
|
|
||||||
*/
|
|
||||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
|
||||||
let done = q.defer<GitRepo>()
|
|
||||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
|
||||||
plugins.shelljs.exec(`cd destinationDirArg && git init`)
|
|
||||||
let newRepo = new GitRepo(destinationDirArg)
|
|
||||||
done.resolve(newRepo)
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
import 'typings-global'
|
// node native
|
||||||
export import path = require('path')
|
import * as path from 'path';
|
||||||
export import beautylog = require('beautylog')
|
|
||||||
export import shelljs = require('shelljs')
|
export { path };
|
||||||
export import smartfile = require('smartfile')
|
|
||||||
export import smartpath = require('smartpath')
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
export import smartstring = require('smartstring')
|
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 nodegit from 'nodegit';
|
||||||
|
|
||||||
|
export { nodegit };
|
||||||
|
16
tslint.json
16
tslint.json
@ -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"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user