Compare commits

...

48 Commits

Author SHA1 Message Date
6ebb7cec81 3.0.1 2023-07-27 13:45:49 +02:00
c64de19815 fix(core): update 2023-07-27 13:45:48 +02:00
26d4753ddf switch to new org scheme 2023-07-11 00:44:24 +02:00
6d5b9f3553 switch to new org scheme 2023-07-10 02:56:04 +02:00
8dd8bd0be1 3.0.0 2022-07-31 15:37:57 +02:00
0bd91c2bda BREAKING CHANGE(core): switch to esm 2022-07-31 15:37:57 +02:00
6ef3e6e6f5 2.0.5 2022-07-31 15:19:20 +02:00
93709f920e fix(core): update 2022-07-31 15:19:19 +02:00
75fa530f73 2.0.4 2022-07-31 15:18:04 +02:00
f5617d9d45 fix(core): update 2022-07-31 15:18:04 +02:00
b46d1e19a7 2.0.3 2022-07-31 15:16:06 +02:00
c8d173807d fix(core): update 2022-07-31 15:16:06 +02:00
5944c7e96f 2.0.2 2022-07-31 15:14:19 +02:00
39ea160fdf fix(core): update 2022-07-31 15:14:18 +02:00
91ca5e53f1 2.0.1 2021-10-22 01:42:42 +02:00
778267bb36 fix(core): update 2021-10-22 01:42:42 +02:00
61407e4854 2.0.0 2021-10-21 19:09:14 +02:00
2771413723 BREAKING CHANGE(dependencies): switch to isomorphic git 2021-10-21 19:09:14 +02:00
b83752a98a 1.0.18 2020-08-15 14:17:09 +00:00
48f71ed1c2 fix(core): update 2020-08-15 14:17:08 +00:00
54ed2f97b8 1.0.17 2020-08-15 13:53:02 +00:00
92198a75c9 fix(core): update 2020-08-15 13:53:02 +00:00
f82a34b1ea 1.0.16 2020-08-15 13:51:39 +00:00
c3b68fa0fc fix(core): update 2020-08-15 13:51:38 +00:00
1af7afd723 1.0.15 2020-08-15 13:51:25 +00:00
66e45154e3 fix(core): update 2020-08-15 13:51:24 +00:00
dcc58a312e 1.0.14 2020-08-15 13:46:57 +00:00
90f57bee1a fix(core): update 2020-08-15 13:46:56 +00:00
98d1f8aea2 1.0.13 2019-08-27 18:21:39 +02:00
1f542367e6 1.0.12 2019-08-27 16:02:04 +02:00
201a5014ed fix(core): update 2019-08-27 16:02:04 +02:00
6cc245ae7e 1.0.11 2019-06-20 14:19:54 +02:00
1377fb6eb7 fix(core): update 2019-06-20 14:19:54 +02:00
daf8c80513 1.0.10 2019-06-20 14:10:42 +02:00
46fce49356 fix(core): update 2019-06-20 14:10:42 +02:00
8616613a95 1.0.9 2019-06-19 14:10:17 +02:00
352e4d8e96 fix(core): update 2019-06-19 14:10:16 +02:00
c2105ce78f 1.0.8 2019-06-19 14:00:44 +02:00
2864fc5507 fix(core): update 2019-06-19 14:00:44 +02:00
fea523ff5c 1.0.7 2019-06-18 15:41:04 +02:00
872f2354c5 fix(core): update 2019-06-18 15:41:03 +02:00
ff0318534f 1.0.6 2019-06-18 15:17:50 +02:00
e103074684 fix(core): update 2019-06-18 15:17:50 +02:00
f72beabd90 remove some white space 2016-12-31 23:20:38 +01:00
958a625633 1.0.5 2016-12-31 23:17:07 +01:00
871fd55c5c fix .addAll 2016-12-31 23:17:03 +01:00
07fd9b9fa7 1.0.4 2016-11-26 23:28:41 +01:00
62d6a8d685 add npmextra.json 2016-11-26 23:28:37 +01:00
34 changed files with 5450 additions and 928 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

23
.gitignore vendored
View File

@ -1,13 +1,20 @@
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_*/
# custom

View File

@ -1,49 +0,0 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
- trigger
before_script:
- npmci prepare ssh
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
release:
stage: release
script:
- npmci publish
only:
- tags
tags:
- docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker

View File

@ -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=

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,68 +0,0 @@
# smartgit
smart git wrapper for node.
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/)
## 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/)
## Usage
We recommend the use of TypeScript for best in class intellisense
```javascript
// import smartgit:
import { GitRepo } from 'smartgit'
// Initialize smartgit:
// -- note: there are 3 ways to initialize smartgit
// -- -- 1. with a existing Git repo
// -- -- 2. with a cloned Git repo
// -- -- 3. with a new Git repo
// -- 1. existing Git Repo:
let myExistingGitRepo = new GitRepo('/path/to/existing/git/repo/')
// -- 2. cloned Git Repo:
let myClonedGitRepo: GitRepo
smartgit.createRepoFromClone('git@github.com:username/reponame.git')
.then(gitRepo => { // non blocking
myClonedGitRepo = gitRepo
})
// -- 3. new Git Repo
let myNewGitRepo: GitRepo
smartgit.createRepoFromInit('/path/to/new/folder') // smartgit will create any new folder, be careful
.then(gitRepo => { // non blocking
myNewGitRepo = gitRepo
})
// Using smartgit instance
// -- most used actions
// -- all actions return promises, so make sure to use promise chaining for any dependent tasks
myExistingGitRepo.addAll() // returns promise, stages all changed files
myExistingGitRepo.add(['relative/path/to/file.txt','another/file2.txt']) // returns promise, stages specific files
myExistingGitRepo.commit('my commit message') // returns promise, commits staged files
myExistingGitRepo.status() // returns promise
.then(status => { // Use TypeScript for status type information
})
myExistingGitRepo.check() // returns promise, checks repo health
myExistingGitRepo.remoteAdd('git@github.com:username/reponame.git')
```
Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEs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0FBQSJ9

View File

@ -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(): 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,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;

17
npmextra.json Normal file
View File

@ -0,0 +1,17 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "push.rocks",
"gitrepo": "smartgit",
"description": "smart wrapper for nodegit",
"npmPackagename": "@push.rocks/smartgit",
"license": "MIT"
}
}
}

View File

@ -1,5 +0,0 @@
{
"mode":"default",
"codecov":true,
"coverageTreshold":71
}

View File

@ -1,12 +1,14 @@
{
"name": "smartgit",
"version": "1.0.3",
"description": "smart git wrapper for node",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@push.rocks/smartgit",
"version": "3.0.1",
"description": "smart wrapper for nodegit",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"cleanTest": "rm -rf test/temp*",
"test": "(npm run cleanTest && npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
@ -24,21 +26,35 @@
},
"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"
"@push.rocks/smartenv": "^5.0.5",
"@push.rocks/smartfile": "^10.0.26",
"@push.rocks/smartpath": "^5.0.5",
"@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smartshell": "^3.0.3",
"@push.rocks/smartstring": "^4.0.7",
"@types/minimatch": "^5.1.2",
"isomorphic-git": "^1.24.5"
},
"devDependencies": {
"@types/should": "^8.1.30",
"npmts-g": "^5.2.8",
"should": "^11.1.1",
"typings-test": "^1.0.3"
}
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.8"
},
"private": false,
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

4860
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

85
readme.md Normal file
View File

@ -0,0 +1,85 @@
# @push.rocks/smartgit
smart wrapper for nodegit
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartgit)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartgit)
* [github.com (source mirror)](https://github.com/push.rocks/smartgit)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartgit/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartgit/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartgit/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartgit)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartgit)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartgit)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartgit)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartgit)](https://lossless.cloud)
## Usage
We recommend the use of TypeScript for best in class intellisense
```javascript
// import smartgit:
import { GitRepo } from 'smartgit';
// Initialize smartgit:
// -- note: there are 3 ways to initialize smartgit
// -- -- 1. with a existing Git repo
// -- -- 2. with a cloned Git repo
// -- -- 3. with a new Git repo
// -- 1. existing Git Repo:
let myExistingGitRepo = new GitRepo('/path/to/existing/git/repo/');
// -- 2. cloned Git Repo:
let myClonedGitRepo: GitRepo;
smartgit.createRepoFromClone('git@github.com:username/reponame.git').then((gitRepo) => {
// non blocking
myClonedGitRepo = gitRepo;
});
// -- 3. new Git Repo
let myNewGitRepo: GitRepo;
smartgit
.createRepoFromInit('/path/to/new/folder') // smartgit will create any new folder, be careful
.then((gitRepo) => {
// non blocking
myNewGitRepo = gitRepo;
});
// Using smartgit instance
// -- most used actions
// -- all actions return promises, so make sure to use promise chaining for any dependent tasks
myExistingGitRepo.addAll(); // returns promise, stages all changed files
myExistingGitRepo.add(['relative/path/to/file.txt', 'another/file2.txt']); // returns promise, stages specific files
myExistingGitRepo.commit('my commit message'); // returns promise, commits staged files
myExistingGitRepo
.status() // returns promise
.then((status) => {
// Use TypeScript for status type information
});
myExistingGitRepo.check(); // returns promise, checks repo health
myExistingGitRepo.remoteAdd('git@github.com:username/reponame.git');
```
Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
## Legal
> MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)

View File

@ -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");

Submodule test/temp3 deleted from a261a2ea02

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(paths.temp1);
});
});
describe('.check()', function (done) {
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQixJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUE7QUFDaEMsNkJBQTZCO0FBQzdCLGlDQUFnQztBQUVoQywwQ0FBMEM7QUFDMUMsSUFBSSxLQUFLLEdBQUc7SUFDUixLQUFLLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUM7SUFDbkMsS0FBSyxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsZUFBZSxDQ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UFDVixDQUFDLENBQUMsQ0FBQTtRQUNWLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9

View File

@ -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"}

View File

@ -1,112 +1,29 @@
import 'typings-test'
import beautylog = require('beautylog')
let shelljs = require('shelljs')
import path = require('path')
import * as should from 'should'
import { tap, expect } from '@push.rocks/tapbundle';
import * as smartgit from '../ts/index.js';
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/')
}
import * as smartpath from '@push.rocks/smartpath';
const __dirname = smartpath.get.dirnameFromImportMetaUrl(import.meta.url);
import * as path from 'path';
let testSmartgitInstance: smartgit.Smartgit;
const testRepoDir = path.join(__dirname, '../.nogit/testrepo');
const testRepoDirSmartfile = path.join(__dirname, '../.nogit/pushrocks_smartfile');
tap.test('should create a valid smartgit instance', async () => {
testSmartgitInstance = new smartgit.Smartgit();
await testSmartgitInstance.init();
expect(testSmartgitInstance).toBeInstanceOf(smartgit.Smartgit);
});
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(paths.temp1)
})
})
describe('.check()', function(done) {
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.test('should create a new repo at .nogit', async () => {
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir);
});
tap.test('should clone a repo', async () => {
const gitRepo = await testSmartgitInstance.createRepoByClone(
'https://gitlab.com/push.rocks/smartfile.git',
testRepoDirSmartfile
);
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartgit',
version: '3.0.1',
description: 'smart wrapper for nodegit'
}

View File

@ -1,31 +1,2 @@
import * as q from 'q'
import plugins = require("./smartgit.plugins");
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
}
/**
* 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 * from './smartgit.classes.gitrepo.js';
export * from './smartgit.classes.smartgit.js';

View File

@ -1,150 +1,113 @@
import * as q from 'q'
import * as plugins from './smartgit.plugins'
import * as plugins from './smartgit.plugins.js';
import { Smartgit } from './smartgit.classes.smartgit.js';
/**
* 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 fromCloningIntoDir(
smartgitRefArg: Smartgit,
fromArg: string,
toArg: string
): Promise<GitRepo> {
const dirArg = plugins.path.resolve(toArg);
await plugins.isomorphicGit.clone({
dir: toArg,
fs: smartgitRefArg.envDeps.fs,
http: smartgitRefArg.envDeps.http,
url: fromArg,
});
return new GitRepo(smartgitRefArg, toArg);
}
public static async fromCreatingRepoInDir(
smartgitRefArg: Smartgit,
dirArg: string
): Promise<GitRepo> {
dirArg = plugins.path.resolve(dirArg);
await plugins.isomorphicGit.init({
dir: dirArg,
fs: smartgitRefArg.envDeps.fs,
});
return new GitRepo(smartgitRefArg, dirArg);
}
public static async fromOpeningRepoDir(smartgitRefArg: Smartgit, dirArg: string) {
dirArg = plugins.path.resolve(dirArg);
return new GitRepo(smartgitRefArg, dirArg);
}
// INSTANCE
public smartgitRef: Smartgit;
public repoDir: string;
constructor(smartgitRefArg: Smartgit, repoDirArg: string) {
this.smartgitRef = smartgitRefArg;
this.repoDir = repoDirArg;
}
/**
* lists remotes
*/
public async listRemotes(): Promise<
{
remote: string;
url: string;
}[]
> {
const remotes = await plugins.isomorphicGit.listRemotes({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
});
return remotes;
}
/**
* ensures the existance of a remote within a repository
* @param remoteNameArg
* @param remoteUrlArg
*/
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
const remotes = await this.listRemotes();
const existingRemote = remotes.find((itemArg) => itemArg.remote === remoteNameArg);
if (existingRemote) {
if (existingRemote.url !== remoteUrlArg) {
await plugins.isomorphicGit.deleteRemote({
remote: remoteNameArg,
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
});
} else {
return;
}
}
await plugins.isomorphicGit.addRemote({
remote: remoteNameArg,
fs: this.smartgitRef.envDeps.fs,
url: remoteUrlArg,
});
}
/**
* checks if the Repo is valid
*/
check(): boolean {
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
}
/**
* gets the url for a specific remote
*/
public async getUrlForRemote(remoteName: string): Promise<string> {
const remotes = await this.listRemotes();
const existingRemote = remotes.find((remoteArg) => remoteArg.remote === remoteName);
return existingRemote?.url;
}
/**
* stage all files in working directory
*/
addAll(dirPathArg: string) {
let done = q.defer()
plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`)
done.resolve(dirPathArg)
return done.promise
};
/**
* add a remote to the GitRepo
*/
remoteAdd(remoteNameArg: 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)
public async pushBranchToRemote(branchName: string, remoteName: string) {
await plugins.isomorphicGit.push({
fs: this.smartgitRef.envDeps.fs,
http: this.smartgitRef.envDeps.http,
ref: branchName,
remote: remoteName,
});
}
}

View File

@ -0,0 +1,40 @@
import * as plugins from './smartgit.plugins.js';
import { GitRepo } from './smartgit.classes.gitrepo.js';
export class Smartgit {
public smartenvInstance = new plugins.smartenv.Smartenv();
public envDeps: {
fs: any;
http: any;
} = {
fs: null,
http: null,
};
constructor() {}
public async init() {
if (this.smartenvInstance.isNode) {
this.envDeps.fs = await this.smartenvInstance.getSafeNodeModule('fs');
this.envDeps.http = await this.smartenvInstance.getSafeNodeModule(
'isomorphic-git/http/node/index.js'
);
} else {
throw new Error('currently only node.js is supported.');
}
}
public async createRepoByClone(fromUrlArg: string, toDirArg: string) {
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg);
}
public async createRepoByInit(dirArg: string) {
const repo = await GitRepo.fromCreatingRepoInDir(this, dirArg);
return repo;
}
public async createRepoByOpen(dirArg: string) {
const repo = await GitRepo.fromOpeningRepoDir(this, dirArg);
return repo;
}
}

View File

@ -1,7 +1,17 @@
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 smartenv from '@push.rocks/smartenv';
import * as smartfile from '@push.rocks/smartfile';
import * as smartpath from '@push.rocks/smartpath';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartstring from '@push.rocks/smartstring';
export { smartenv, smartfile, smartpath, smartpromise, smartstring };
// third party
import isomorphicGit from 'isomorphic-git';
export { isomorphicGit };

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}