fix(core): update
This commit is contained in:
parent
f72beabd90
commit
e103074684
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
|
@ -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:
|
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:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- 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:
|
tags:
|
||||||
- docker
|
- 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
|
||||||
|
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)
|
||||||
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartgit)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartgit)
|
||||||
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartgit)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/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/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[![build status](https://gitlab.com/pushrocks/smartgit/badges/master/build.svg)](https://gitlab.com/pushrocks/smartgit/commits/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)
|
[![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)
|
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartgit.svg)](https://www.npmjs.com/package/@pushrocks/smartgit)
|
||||||
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartgit/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartgit/master/dependencies/npm)
|
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartgit/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartgit)
|
||||||
[![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->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[![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->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.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-prettier-ff69b4.svg)](https://prettier.io/)
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](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
|
||||||
|
|
||||||
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)
|
[![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
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) => q.Promise<GitRepo>;
|
|
28
dist/index.js
vendored
28
dist/index.js
vendored
@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDhDQUErQztBQUUvQyx5RUFBb0Q7QUFFaEQscURBQU87QUFHWDs7R0FFRztBQUNRLFFBQUEsb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
|||||||
/// <reference types="q" />
|
|
||||||
import * as q from 'q';
|
|
||||||
/**
|
|
||||||
* class GitRepo allows access to git directories from node
|
|
||||||
*/
|
|
||||||
export declare class GitRepo {
|
|
||||||
repoBase: string;
|
|
||||||
constructor(repoBaseArg: string);
|
|
||||||
/**
|
|
||||||
* checks if the Repo is valid
|
|
||||||
*/
|
|
||||||
check(): boolean;
|
|
||||||
/**
|
|
||||||
* stage all files in working directory
|
|
||||||
* @executes SYNC
|
|
||||||
*/
|
|
||||||
addAll(): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* add a remote to the GitRepo
|
|
||||||
*/
|
|
||||||
remoteAdd(remoteNameArg: string, remoteLinkArg: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* list remotes for a Gip
|
|
||||||
*/
|
|
||||||
remoteList(): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* remove remote
|
|
||||||
*/
|
|
||||||
remoteRemove(dirPathArg: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* commit all files that are currently staged
|
|
||||||
*/
|
|
||||||
commit(commitMessage: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* pull latest changes from remote
|
|
||||||
*/
|
|
||||||
pull(sourceArg?: string, branchArg?: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* push new commits to remote
|
|
||||||
*/
|
|
||||||
push(remoteNameArg?: string, remoteBranchArg?: string): q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* sync
|
|
||||||
*/
|
|
||||||
sync(): void;
|
|
||||||
/**
|
|
||||||
* get the current status
|
|
||||||
*/
|
|
||||||
status(): q.Promise<{}>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* creates a new GitRepo Instance after cloning a project
|
|
||||||
*/
|
|
||||||
export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise<GitRepo>;
|
|
||||||
/**
|
|
||||||
* creates a new GitRepo instance after initializing a new Git Repository
|
|
||||||
*/
|
|
||||||
export declare let createRepoFromInit: (destinationDirArg: string) => void;
|
|
142
dist/smartgit.classes.gitrepo.js
vendored
142
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
|
|
@ -8,5 +8,15 @@
|
|||||||
"globalNpmTools": [
|
"globalNpmTools": [
|
||||||
"npmts"
|
"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
2535
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
48
package.json
48
package.json
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "smartgit",
|
"name": "@pushrocks/smartgit",
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"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)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -24,21 +24,31 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/minimatch": "*",
|
"@pushrocks/smartfile": "^7.0.2",
|
||||||
"@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.8",
|
||||||
"smartpath": "^3.2.5",
|
"nodegit": "^0.24.3"
|
||||||
"smartstring": "^2.0.22",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@gitzone/tsbuild": "^2.1.11",
|
||||||
"npmts-g": "^5.2.8",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"should": "^11.1.1",
|
"@pushrocks/tapbundle": "^3.0.9",
|
||||||
"typings-test": "^1.0.3"
|
"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
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
110
test/test.js
110
test/test.js
@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQixJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUE7QUFDaEMsNkJBQTZCO0FBQzdCLGlDQUFnQztBQUVoQywwQ0FBMEM7QUFDMUMsSUFBSSxLQUFLLEdBQUc7SUFDUixLQUFLLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUM7SUFDbkMsS0FBSyxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsZUFBZS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0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,QAAQ,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC3C,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/B,QAAQ,CAAC,UAAU,EAAC;IAChB,QAAQ,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"}
|
|
112
test/test.ts
112
test/test.ts
@ -1,110 +1,4 @@
|
|||||||
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')
|
tap.start();
|
||||||
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()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
41
ts/index.ts
41
ts/index.ts
@ -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'
|
import { GitRepo } from './smartgit.classes.gitrepo';
|
||||||
export {
|
export { GitRepo };
|
||||||
GitRepo
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a new GitRepo Instance after cloning a project
|
* creates a new GitRepo Instance after cloning a project
|
||||||
*/
|
*/
|
||||||
export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
export const createRepoFromClone = async (fromArg: string, toArg: string): Promise<GitRepo> => {
|
||||||
let done = q.defer<GitRepo>()
|
let done = q.defer<GitRepo>();
|
||||||
plugins.smartfile.fs.ensureDir(toArg)
|
plugins.smartfile.fs.ensureDir(toArg);
|
||||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`)
|
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
|
||||||
let newRepo = new GitRepo(toArg)
|
let newRepo = new GitRepo(toArg);
|
||||||
done.resolve(newRepo)
|
done.resolve(newRepo);
|
||||||
return done.promise
|
return done.promise;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a new GitRepo instance after initializing a new Git Repository
|
* creates a new GitRepo instance after initializing a new Git Repository
|
||||||
*/
|
*/
|
||||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
export const createRepoFromInit = async (destinationDirArg: string): Promise<GitRepo> => {
|
||||||
let done = q.defer<GitRepo>()
|
const done = q.defer<GitRepo>();
|
||||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
plugins.smartfile.fs.ensureDir(destinationDirArg);
|
||||||
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`)
|
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`);
|
||||||
let newRepo = new GitRepo(destinationDirArg)
|
let newRepo = new GitRepo(destinationDirArg);
|
||||||
done.resolve(newRepo)
|
done.resolve(newRepo);
|
||||||
return done.promise
|
return done.promise;
|
||||||
}
|
};
|
||||||
|
@ -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
|
* class GitRepo allows access to git directories from node
|
||||||
*/
|
*/
|
||||||
export class GitRepo {
|
export class GitRepo {
|
||||||
repoBase: string
|
// STATIC
|
||||||
constructor(repoBaseArg: string) {
|
|
||||||
this.repoBase = repoBaseArg
|
|
||||||
if (!this.check()) {
|
|
||||||
throw new Error('no valid git repo')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the Repo is valid
|
|
||||||
*/
|
|
||||||
check(): boolean {
|
|
||||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stage all files in working directory
|
|
||||||
* @executes SYNC
|
|
||||||
*/
|
|
||||||
addAll() {
|
|
||||||
let done = q.defer()
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git add -A && git status)`)
|
|
||||||
done.resolve(this.repoBase)
|
|
||||||
return done.promise
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add a remote to the GitRepo
|
|
||||||
*/
|
|
||||||
remoteAdd(remoteNameArg: string, remoteLinkArg: string) {
|
|
||||||
let done = q.defer()
|
|
||||||
if (!remoteNameArg) {
|
|
||||||
let err = new Error('smartgit.remote.add expects a valid remote name')
|
|
||||||
plugins.beautylog.error(err.message)
|
|
||||||
done.reject(err)
|
|
||||||
return done.promise
|
|
||||||
};
|
|
||||||
if (!remoteLinkArg) {
|
|
||||||
let err = new Error()
|
|
||||||
plugins.beautylog.error(err.message)
|
|
||||||
done.reject(err)
|
|
||||||
return done.promise
|
|
||||||
};
|
|
||||||
|
|
||||||
// if everything is all right proceed
|
|
||||||
plugins.shelljs.exec(`cd ${this.repoBase} && git remote add ${remoteNameArg} ${remoteLinkArg}`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* list remotes for a Gip
|
|
||||||
*/
|
|
||||||
remoteList() {
|
|
||||||
let done = q.defer()
|
|
||||||
let remotes = {}
|
|
||||||
plugins.shelljs.exec(`cd ${this.repoBase} && git remote -v`)
|
|
||||||
done.resolve(remotes)
|
|
||||||
return done.promise
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* remove remote
|
|
||||||
*/
|
|
||||||
remoteRemove(dirPathArg: string) {
|
|
||||||
let done = q.defer()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* commit all files that are currently staged
|
|
||||||
*/
|
|
||||||
commit(commitMessage: string) {
|
|
||||||
let done = q.defer()
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git commit -m "${commitMessage}")`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pull latest changes from remote
|
|
||||||
*/
|
|
||||||
pull(sourceArg: string = '', branchArg: string = '') {
|
|
||||||
let done = q.defer()
|
|
||||||
// if everything is allright proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git pull ${sourceArg} ${branchArg})`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* push new commits to remote
|
|
||||||
*/
|
|
||||||
push(remoteNameArg: string = '', remoteBranchArg: string = '') {
|
|
||||||
let done = q.defer()
|
|
||||||
// if everything seems allright proceed
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git push ${remoteNameArg} ${remoteBranchArg})`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sync
|
|
||||||
*/
|
|
||||||
sync() {
|
|
||||||
this.pull().then(() => {
|
|
||||||
this.push()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the current status
|
|
||||||
*/
|
|
||||||
status() {
|
|
||||||
let done = q.defer()
|
|
||||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git status)`)
|
|
||||||
done.resolve()
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a new GitRepo Instance after cloning a project
|
* creates a new GitRepo Instance after cloning a project
|
||||||
*/
|
*/
|
||||||
export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
public static async createRepoFromClone(fromArg: string, toArg: string): Promise<GitRepo> {
|
||||||
let done = q.defer<GitRepo>()
|
return new 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
|
* creates a new GitRepo instance after initializing a new Git Repository
|
||||||
*/
|
*/
|
||||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
public static async createRepoFromInit(destinationDirArg: string): Promise<GitRepo> {
|
||||||
let done = q.defer<GitRepo>()
|
return new GitRepo();
|
||||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
}
|
||||||
plugins.shelljs.exec(`cd destinationDirArg && git init`)
|
|
||||||
let newRepo = new GitRepo(destinationDirArg)
|
// INSTANCE
|
||||||
done.resolve(newRepo)
|
nodegitRepo;
|
||||||
}
|
}
|
||||||
|
@ -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 * as 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"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user