Compare commits

..

No commits in common. "master" and "v0.1.7" have entirely different histories.

65 changed files with 868 additions and 7859 deletions

View File

@ -1,66 +0,0 @@
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

@ -1,124 +0,0 @@
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 @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

28
.gitignore vendored
View File

@ -1,20 +1,14 @@
.nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/ node_modules/
.settings/
.idea/
test/temp/
test/temp2/
coverage/
docs/
# caches #npm devug
.yarn/ npm-debug.log
.cache/
.rpt2_cache
# builds ts/*.js
dist/ ts/*.js.map
dist_*/ ts/typings/
# custom

49
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,49 @@
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

19
.travis.yml Normal file
View File

@ -0,0 +1,19 @@
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
View File

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

26
.vscode/settings.json vendored
View File

@ -1,26 +0,0 @@
{
"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) The MIT License (MIT)
Copyright (c) 2015 Lossless GmbH Copyright (c) 2015 Push.Rocks
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

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# smartgit is an easy wrapper for nodegit
a wrapper for git. This plugin does not use nodegit as nodegit appears to have too many bugs for now.
### Buildstatus/Dependencies
[![build status](https://gitlab.com/pushrocks/smartgit/badges/master/build.svg)](https://gitlab.com/pushrocks/smartgit/commits/master)
[![devDependency Status](https://david-dm.org/pushrocks/smartgit/dev-status.svg)](https://david-dm.org/pushrocks/smartgit#info=devDependencies)
[![Coverage Status](https://coveralls.io/repos/github/pushrocks/smartgit/badge.svg?branch=master)](https://coveralls.io/github/pushrocks/smartgit?branch=master)
### Usage
This plugin exposes some easified method wrappers for nodegit.
This limits options but reduces errors (TypeScript) and speeds up usage.
Features:
* clone a git repo
* init a new repo
* create a new git repo
* add changes and make a new commit
* commit changes
* push changes
* add/remove remotes
Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment

View File

@ -1,63 +0,0 @@
# Changelog
## 2024-06-23 - 3.1.1 - fix(documentation)
Remove outdated changelog entries
## 2024-06-23 - 3.1.0 - gitrepo
Enhancements and fixes to GitRepo
- Enhance GitRepo to include commit date and version information
## 2024-06-22 - 3.0.3 to 3.0.4 - core & GitRepo
General updates and new feature addition
- Fixed core functionality
- Added diff function in GitRepo
## 2023-11-15 - 3.0.1 to 3.0.2 - core, tsconfig, npmextra
Minor updates and fixes
- Fixed core functionality
- Updated tsconfig and npmextra.json
## 2023-07-10 - 3.0.0 - core
Structural changes to organization scheme
- Switched to a new organizational scheme
## 2023-07-27 - 3.0.0 to 3.0.1 - core
Structural changes and updates
- Fixed core functionality
- Switched to new organizational scheme
## 2022-07-31 - 2.0.2 to 3.0.0 - core
Breaking changes and updates
- Switching to ESM for core
- Fixed core functionality
## 2021-10-22 - 1.0.18 to 2.0.1 - dependencies, core
Breaking changes and updates
- Switched to isomorphic git dependencies
- Fixed core functionality
## 2020-08-15 - 1.0.14 to 1.0.18 - core
Fixes
- Fixed core functionality in multiple patches
## 2019-06-18 - 1.0.5 to 1.0.10 - core
Fixes
- Fixed core functionality in multiple patches
## 2016-06-23 - 0.0.10 to 0.1.11 - gitlab & other fixes
Initial implementations and setup
- Fixed README and merge issues
- Updated gitlab.yml and CI settings
- Implemented new class approach and other updates
- Removed unnecessary imports, postinstall
- Added npmextra.json, CI tests, SSH key support

8
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
export { add } from "./smartgit.add";
export { clone } from "./smartgit.clone";
export { commit } from "./smartgit.commit";
export { init } from "./smartgit.init";
export { pull } from "./smartgit.pull";
export { push } from "./smartgit.push";
export { remote } from "./smartgit.remote";
export { status } from "./smartgit.status";

18
dist/index.js vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
var smartgit_add_1 = require("./smartgit.add");
exports.add = smartgit_add_1.add;
var smartgit_clone_1 = require("./smartgit.clone");
exports.clone = smartgit_clone_1.clone;
var smartgit_commit_1 = require("./smartgit.commit");
exports.commit = smartgit_commit_1.commit;
var smartgit_init_1 = require("./smartgit.init");
exports.init = smartgit_init_1.init;
var smartgit_pull_1 = require("./smartgit.pull");
exports.pull = smartgit_pull_1.pull;
var smartgit_push_1 = require("./smartgit.push");
exports.push = smartgit_push_1.push;
var smartgit_remote_1 = require("./smartgit.remote");
exports.remote = smartgit_remote_1.remote;
var smartgit_status_1 = require("./smartgit.status");
exports.status = smartgit_status_1.status;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsNkJBQWtCLGdCQUFnQixDQUFDO0FBQTNCLGlDQUEyQjtBQUNuQywrQkFBb0Isa0JBQWtCLENBQUM7QUFBL0IsdUNBQStCO0FBQ3ZDLGdDQUFxQixtQkFBbUIsQ0FBQztBQUFqQywwQ0FBaUM7QUFDekMsOEJBQW1CLGlCQUFpQixDQUFDO0FBQTdCLG9DQUE2QjtBQUNyQyw4QkFBbUIsaUJBQWlCLENBQUM7QUFBN0Isb0NBQTZCO0FBQ3JDLDhCQUFtQixpQkFBaUIsQ0FBQztBQUE3QixvQ0FBNkI7QUFDckMsZ0NBQXFCLG1CQUFtQixDQUFDO0FBQWpDLDBDQUFpQztBQUN6QyxnQ0FBcUIsbUJBQW1CLENBQUM7QUFBakMsMENBQWlDIn0=

0
dist/postinstall.d.ts vendored Normal file
View File

3
dist/postinstall.js vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
var shelljs = require("shelljs");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9zdGluc3RhbGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wb3N0aW5zdGFsbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDIn0=

3
dist/smartgit.add.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export declare let add: {
addAll: (dirPathArg: string) => any;
};

20
dist/smartgit.add.js vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var plugins = require("./smartgit.plugins");
var helpers = require("./smartgit.helpers");
var addAll = function (dirPathArg) {
var done = plugins.Q.defer();
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.add expects a valid git directory!");
done.reject();
return done.promise;
}
;
// if everything is ok proceed
plugins.shelljs.exec("(cd " + dirPathArg + " && git add -A && git status)");
done.resolve(dirPathArg);
return done.promise;
};
exports.add = {
addAll: addAll
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuYWRkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuYWRkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFOUMsSUFBSSxNQUFNLEdBQUcsVUFBQyxVQUFpQjtJQUMzQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQSxDQUFDLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDcEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsNkNBQTZDLENBQUMsQ0FBQztRQUN2RSxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLDhCQUE4QjtJQUM5QixPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsa0NBQStCLENBQUMsQ0FBQztJQUN2RSxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQ3pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQUVTLFdBQUcsR0FBRztJQUNiLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ==

2
dist/smartgit.check.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
declare var _default: (repoArg: any) => boolean;
export = _default;

5
dist/smartgit.check.js vendored Normal file
View File

@ -0,0 +1,5 @@
"use strict";
module.exports = function (repoArg) {
return true;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY2hlY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGdpdC5jaGVjay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsaUJBQVMsVUFBUyxPQUFPO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUM7QUFDaEIsQ0FBQyxDQUFDIn0=

7
dist/smartgit.clone.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
export declare let clone: (optionsArg: {
from: string;
to: string;
key?: string;
keyPath?: string;
keyPassphrase?: string;
}) => any;

10
dist/smartgit.clone.js vendored Normal file
View File

@ -0,0 +1,10 @@
"use strict";
var plugins = require("./smartgit.plugins");
exports.clone = function (optionsArg) {
var done = plugins.Q.defer();
plugins.smartfile.fs.ensureDir(optionsArg.to);
plugins.shelljs.exec("git clone " + optionsArg.from + " " + optionsArg.to);
done.resolve();
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY2xvbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGdpdC5jbG9uZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUdwQyxhQUFLLEdBQUcsVUFBQyxVQU1uQjtJQUNHLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUMsQ0FBQztJQUM5QyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxlQUFhLFVBQVUsQ0FBQyxJQUFJLFNBQUksVUFBVSxDQUFDLEVBQUksQ0FBQyxDQUFDO0lBQ3RFLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9

1
dist/smartgit.commit.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let commit: (dirPathArg: string, commitMessage: string) => any;

17
dist/smartgit.commit.js vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
var plugins = require("./smartgit.plugins");
var helpers = require("./smartgit.helpers");
exports.commit = function (dirPathArg, commitMessage) {
var done = plugins.Q.defer();
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.commit expects a valid git directory");
done.reject();
return done.promise;
}
;
// if everything is all right proceed
plugins.shelljs.exec("(cd " + dirPathArg + " && git commit -m \"" + commitMessage + "\")");
done.resolve();
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY29tbWl0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuY29tbWl0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsY0FBTSxHQUFHLFVBQUMsVUFBaUIsRUFBQyxhQUFvQjtJQUN2RCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQSxDQUFDLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDcEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsK0NBQStDLENBQUMsQ0FBQztRQUN6RSxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLHFDQUFxQztJQUNyQyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsNEJBQXNCLGFBQWEsUUFBSSxDQUFDLENBQUM7SUFDL0UsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDIn0=

1
dist/smartgit.helpers.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let isGitDirectory: (dirPathArg: any) => boolean;

11
dist/smartgit.helpers.js vendored Normal file
View File

@ -0,0 +1,11 @@
"use strict";
var plugins = require("./smartgit.plugins");
exports.isGitDirectory = function (dirPathArg) {
try {
return plugins.smartfile.fs.isDirectory(plugins.path.join(dirPathArg, ".git"));
}
catch (err) {
return false;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsc0JBQWMsR0FBRyxVQUFDLFVBQVU7SUFDbkMsSUFBSSxDQUFDO1FBQ0QsTUFBTSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFdBQVcsQ0FDbkMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFDLE1BQU0sQ0FBQyxDQUN2QyxDQUFDO0lBQ04sQ0FDQTtJQUFBLEtBQUssQ0FBQSxDQUFDLEdBQUcsQ0FBQyxDQUFBLENBQUM7UUFDUCxNQUFNLENBQUMsS0FBSyxDQUFDO0lBQ2pCLENBQUM7QUFDTCxDQUFDLENBQUEifQ==

1
dist/smartgit.init.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let init: (dirPathArg: string) => any;

15
dist/smartgit.init.js vendored Normal file
View File

@ -0,0 +1,15 @@
"use strict";
var plugins = require("./smartgit.plugins");
exports.init = function (dirPathArg) {
var done = plugins.Q.defer();
if (typeof dirPathArg == "undefined") {
plugins.beautylog.error("smartgit.init requires an absolute directory path!");
return;
}
;
plugins.smartfile.fs.ensureDir(dirPathArg);
plugins.shelljs.exec("(cd " + dirPathArg + " && git init)");
done.resolve(dirPathArg);
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LmluaXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFFcEMsWUFBSSxHQUFHLFVBQUMsVUFBaUI7SUFDaEMsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUMsQ0FBQyxPQUFPLFVBQVUsSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ25DLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLG9EQUFvRCxDQUFDLENBQUM7UUFDOUUsTUFBTSxDQUFDO0lBQ1gsQ0FBQztJQUFBLENBQUM7SUFDRixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsVUFBVSxDQUFDLENBQUM7SUFDM0MsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsU0FBTyxVQUFVLGtCQUFlLENBQUMsQ0FBQztJQUN2RCxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQ3pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9

8
dist/smartgit.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
import "typings-global";
export import path = require("path");
export import beautylog = require("beautylog");
export declare let Q: any;
export declare let shelljs: any;
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");
export import smartstring = require("smartstring");

10
dist/smartgit.plugins.js vendored Normal file
View File

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

1
dist/smartgit.pull.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let pull: (dirPathArg: string, sourceArg?: string, branchArg?: string) => any;

19
dist/smartgit.pull.js vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
var plugins = require("./smartgit.plugins");
var helpers = require("./smartgit.helpers");
exports.pull = function (dirPathArg, sourceArg, branchArg) {
if (sourceArg === void 0) { sourceArg = ""; }
if (branchArg === void 0) { branchArg = ""; }
var done = plugins.Q.defer();
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.pull expects a valid git directory");
done.reject();
return done.promise;
}
;
// if everything is allright proceed
plugins.shelljs.exec("(cd " + dirPathArg + " && git pull " + sourceArg + " " + branchArg + ")");
done.resolve(dirPathArg);
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucHVsbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnB1bGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDOUMsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUVuQyxZQUFJLEdBQUcsVUFBQyxVQUFpQixFQUFDLFNBQXFCLEVBQUUsU0FBcUI7SUFBNUMseUJBQXFCLEdBQXJCLGNBQXFCO0lBQUUseUJBQXFCLEdBQXJCLGNBQXFCO0lBQzdFLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsRUFBRSxDQUFBLENBQUMsQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUEsQ0FBQztRQUNwQyxPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyw2Q0FBNkMsQ0FBQyxDQUFDO1FBQ3ZFLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQztRQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7SUFBQSxDQUFDO0lBQ0Ysb0NBQW9DO0lBQ3BDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFNBQU8sVUFBVSxxQkFBZ0IsU0FBUyxTQUFJLFNBQVMsTUFBRyxDQUFDLENBQUM7SUFDakYsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUN6QixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUMifQ==

1
dist/smartgit.push.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let push: (dirPathArg: string, sourceArg?: string, branchArg?: string) => any;

18
dist/smartgit.push.js vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
var plugins = require("./smartgit.plugins");
var helpers = require("./smartgit.helpers");
exports.push = function (dirPathArg, sourceArg, branchArg) {
if (sourceArg === void 0) { sourceArg = ""; }
if (branchArg === void 0) { branchArg = ""; }
var done = plugins.Q.defer();
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.push expects a valid git directory");
done.reject();
return done.promise;
}
// if everything seems allright proceed
plugins.shelljs.exec("(cd " + dirPathArg + " && git status)");
done.resolve();
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucHVzaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnB1c2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDOUMsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUVuQyxZQUFJLEdBQUcsVUFBQyxVQUFpQixFQUFFLFNBQXFCLEVBQUUsU0FBcUI7SUFBNUMseUJBQXFCLEdBQXJCLGNBQXFCO0lBQUUseUJBQXFCLEdBQXJCLGNBQXFCO0lBQzlFLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsRUFBRSxDQUFBLENBQUMsQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUEsQ0FBQztRQUNwQyxPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyw2Q0FBNkMsQ0FBQyxDQUFDO1FBQ3ZFLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQztRQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7SUFDRCx1Q0FBdUM7SUFDdkMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsU0FBTyxVQUFVLG9CQUFpQixDQUFDLENBQUM7SUFDekQsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDIn0=

5
dist/smartgit.remote.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
export declare let remote: {
add: (dirPathArg: any, remoteNameArg: string, remoteLinkArg: string) => any;
list: (dirPathArg: any) => any;
remove: (dirPathArg: string) => any;
};

61
dist/smartgit.remote.js vendored Normal file
View File

@ -0,0 +1,61 @@
"use strict";
var plugins = require("./smartgit.plugins");
var helpers = require("./smartgit.helpers");
var add = function (dirPathArg, remoteNameArg, remoteLinkArg) {
var done = plugins.Q.defer();
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.remote.add expects a valid git directory");
done.reject();
return done.promise;
}
;
if (!remoteNameArg) {
plugins.beautylog.error("smartgit.remote.add expects a valid remote name");
done.reject();
return done.promise;
}
;
if (!remoteLinkArg) {
plugins.beautylog.error("smartgit.remote.add expects a valid remote link");
done.reject();
return done.promise;
}
;
// if everything is all right proceed
plugins.shelljs.exec("cd " + dirPathArg + " && git remote add " + remoteNameArg + " " + remoteLinkArg);
exports.remote.list(dirPathArg);
done.resolve();
return done.promise;
};
var check = function (dirPathArg, remoteNameArg, remoteLinkArg) {
};
var list = function (dirPathArg) {
var done = plugins.Q.defer();
var remotes = {};
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.remote.list expects a valid git directory");
done.reject();
return done.promise;
}
;
// if everything is all right proceed
plugins.shelljs.exec("cd " + dirPathArg + " && git remote -v").stdout;
done.resolve(remotes);
return done.promise;
};
var remove = function (dirPathArg) {
var done = plugins.Q.defer();
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.remote.remove expects a valid git directory");
done.reject();
return done.promise;
}
;
// if everything is all right
};
exports.remote = {
add: add,
list: list,
remove: remove
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucmVtb3RlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQucmVtb3RlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFOUMsSUFBSSxHQUFHLEdBQUcsVUFBQyxVQUFVLEVBQUMsYUFBb0IsR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BQUMsQ0FBQyxDQUFBLENBQUM7UUFDcEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsc0RBQXNELENBQUMsQ0FBQztRQUNoRixJQUFJLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLDhCQUE4QjtBQUNsQyxDQUFDLENBQUE7QUFFVSxjQUFNLEdBQUc7SUFDaEIsR0FBRyxFQUFFLEdBQUc7SUFDUixJQUFJLEVBQUUsSUFBSTtJQUNWLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ==

1
dist/smartgit.status.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let status: (dirPathArg: string) => any;

16
dist/smartgit.status.js vendored Normal file
View File

@ -0,0 +1,16 @@
"use strict";
var plugins = require("./smartgit.plugins");
var helpers = require("./smartgit.helpers");
exports.status = function (dirPathArg) {
var done = plugins.Q.defer();
if (!helpers.isGitDirectory(dirPathArg)) {
plugins.beautylog.error("smartgit.status expects a valid git directory");
done.reject();
return done.promise;
}
// if everything seems allright proceed
plugins.shelljs.exec("(cd " + dirPathArg + " && git status)");
done.resolve();
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuc3RhdHVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuc3RhdHVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsY0FBTSxHQUFHLFVBQUMsVUFBaUI7SUFDbEMsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3BDLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLCtDQUErQyxDQUFDLENBQUM7UUFDekUsSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDO1FBQ2QsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQztJQUNELHVDQUF1QztJQUN2QyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsb0JBQWlCLENBQUMsQ0FBQztJQUN6RCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7SUFDZixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUMifQ==

90
index.js Normal file
View File

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

View File

@ -1,31 +0,0 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartgit",
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.",
"npmPackagename": "@push.rocks/smartgit",
"license": "MIT",
"keywords": [
"git",
"nodegit",
"version control",
"git wrapper",
"programming",
"development",
"code management",
"repository management",
"git operations"
]
}
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

5
npmts.json Normal file
View File

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

View File

@ -1,69 +1,42 @@
{ {
"name": "@push.rocks/smartgit", "name": "smartgit",
"version": "3.1.1", "version": "0.1.7",
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.", "description": "an easy wrapper for git",
"main": "dist_ts/index.js", "main": "dist/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist/index.d.ts",
"type": "module",
"scripts": { "scripts": {
"test": "(tstest test/)", "cleanTest": "rm -rf test/temp*",
"build": "(tsbuild --web --allowimplicitany)", "test": "(npm run cleanTest && npmts)",
"buildDocs": "tsdoc" "install": "node dist/postinstall.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://code.foss.global/push.rocks/smartgit.git" "url": "https://gitlab.com/pushrocks/smartgit.git"
}, },
"keywords": [ "keywords": [
"git", "json",
"nodegit", "jade",
"version control", "template"
"git wrapper",
"programming",
"development",
"code management",
"repository management",
"git operations"
], ],
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)", "author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/smartgit/issues" "url": "https://gitlab.com/pushrocks/smartgit/issues"
}, },
"homepage": "https://code.foss.global/push.rocks/smartgit", "homepage": "https://gitlab.com/pushrocks/smartgit",
"dependencies": { "dependencies": {
"@push.rocks/smartenv": "^5.0.12", "@types/minimatch": "*",
"@push.rocks/smartfile": "^11.0.20", "beautylog": "^5.0.13",
"@push.rocks/smartpath": "^5.0.18", "q": "^1.4.1",
"@push.rocks/smartpromise": "^4.0.2", "shelljs": "^0.7.0",
"@push.rocks/smartshell": "^3.0.5", "smartfile": "^4.0.10",
"@push.rocks/smartstring": "^4.0.15", "smartpath": "^3.2.2",
"@push.rocks/smarttime": "^4.0.6", "smartstring": "^2.0.10",
"@types/diff": "^5.2.1", "typings-global": "^1.0.5"
"@types/minimatch": "^5.1.2",
"diff": "^5.2.0",
"isomorphic-git": "^1.25.10"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.80", "npmts-g": "^5.2.6",
"@git.zone/tsrun": "^1.2.44", "should": "^9.0.2",
"@git.zone/tstest": "^1.0.90", "typings-test": "^1.0.1"
"@push.rocks/tapbundle": "^5.0.23" }
},
"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"
]
} }

6971
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

137
readme.md
View File

@ -1,137 +0,0 @@
# @push.rocks/smartgit
smart wrapper for nodegit
## Install
To install @push.rocks/smartgit, use the following command with npm:
```bash
npm install @push.rocks/smartgit --save
```
Or if you prefer using yarn:
```bash
yarn add @push.rocks/smartgit
```
Make sure you have `node` installed on your system to use this package.
## Usage
This guide assumes familiarity with TypeScript and basic Git operations. The `@push.rocks/smartgit` module offers a sophisticated, promise-based interface to interact with Git repositories in a Node.js environment, abstracting over the `isomorphic-git` library and adding additional functionality.
### Setting Up
First, you need to import `Smartgit` and other necessary classes from the package. This is also when you'd typically configure any additional settings or dependencies required by your project.
```typescript
import { Smartgit } from '@push.rocks/smartgit';
// Initialize the Smartgit instance
const smartgit = new Smartgit();
await smartgit.init();
```
### Creating, Cloning, and Opening Repositories
With `Smartgit`, you can easily manage local repositories by creating new ones, cloning existing repositories, or opening an already existing local repository.
#### Creating a New Repository
```typescript
const pathToNewRepo = '/path/to/your/new/repo';
const newRepo = await smartgit.createRepoByInit(pathToNewRepo);
```
#### Cloning a Repository
```typescript
const cloneUrl = 'https://github.com/yourusername/your-repo.git';
const pathToClone = '/path/to/clone/repo';
const clonedRepo = await smartgit.createRepoByClone(cloneUrl, pathToClone);
```
#### Opening an Existing Repository
```typescript
const pathToExistingRepo = '/path/to/your/existing/repo';
const existingRepo = await smartgit.createRepoByOpen(pathToExistingRepo);
```
### Working with Git Operations
`Smartgit` simplifies common Git operations, making it easy to execute commands like add, commit, push, and more programmatically.
#### Adding Changes
To stage changes, you can add all changes or specify particular files.
```typescript
// Add all changes to staging
await existingRepo.addAll();
// Or specify particular files
await existingRepo.add(['file1.txt', 'path/to/file2.txt']);
```
#### Committing Changes
Once changes are staged, you can commit them.
```typescript
await existingRepo.commit('Your commit message');
```
#### Pushing to a Remote
Before pushing, ensure a remote is set up correctly, then push your changes.
```typescript
await existingRepo.ensureRemote('origin', 'https://github.com/yourusername/your-repo.git');
await existingRepo.pushBranchToRemote('main', 'origin');
```
### Advanced Features
`Smartgit` also supports more advanced Git functionalities, such as dealing with branches, managing remotes, and checking repository status.
#### Listing Remotes
```typescript
const remotes = await existingRepo.listRemotes();
console.log(remotes);
```
#### Working with Branches
Branch management such as creating new branches or checking out existing ones can be done through the underlying `isomorphic-git` functions, with `Smartgit` making the setup and usage straightforward.
### Practical Tips
- When dealing with asynchronous operations, especially in sequences that depend on the outcome of previous steps (e.g., staging, committing, and pushing), ensure proper error handling, either using `.then().catch()` chains or `try/catch` blocks with async/await.
- For complex Git workflows, consider combining `Smartgit`'s capabilities with other Node.js modules or scripts to automate and streamline your processes.
### Conclusion
`@push.rocks/smartgit` provides a versatile and powerful toolkit for Git operations in Node.js applications. By abstracting the complexities of interacting with Git repositories, it enables developers to focus more on developing their logic and less on the intricacies of Git commands. Whether you're managing local repositories, automating deployment workflows, or integrating Git operations into your applications, `Smartgit` offers a comprehensive set of features to address your needs.
For further examples, contributions, and issues, please refer to the [project's repository](https://gitlab.com/pushrocks/smartgit) and consider contributing to or starring the project if you find it useful.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

9
test.js Normal file
View File

@ -0,0 +1,9 @@
/// <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");

2
test/test.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import "typings-test";
import "should";

84
test/test.js Normal file
View File

@ -0,0 +1,84 @@
"use strict";
require("typings-test");
var shelljs = require("shelljs");
var path = require("path");
require("should");
var smartgit = require("../dist/index");
var 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 () {
describe(".clone", function () {
it("should clone a repository using ssh and sshkey", function (done) {
this.timeout(40000);
smartgit.clone({
from: "git@gitlab.com:sandboxzone/sandbox-testrepo.git",
to: paths.temp
}).then(function () {
done();
});
});
it("should clone a repository using https", function (done) {
this.timeout(40000);
smartgit.clone({
from: "https://gitlab.com/sandboxzone/sandbox-testrepo.git",
to: paths.temp2
}).then(function () {
done();
});
});
});
describe(".add", function () {
it("should error for noGit", function () {
smartgit.add.addAll(paths.noGit);
});
it("should add a file to an existing repository", function () {
shelljs.exec("(cd " + paths.temp + " && cp ../test.js .)");
smartgit.add.addAll(paths.temp);
});
});
describe("commit", function () {
it("should error for noGit", function () {
smartgit.commit(paths.noGit, "some commit message");
});
it("should commit a new file to an existing repository", function () {
smartgit.commit(paths.temp, "added a new file");
});
});
describe("init", function () {
it("should error for noGit", function () {
smartgit.init(paths.noGit);
});
it("should init a new git", function () {
smartgit.init(paths.temp3);
});
});
describe("pull", function () {
this.timeout(40000);
it("should error for noGit", function () {
smartgit.pull(paths.noGit);
});
it("should pull from origin", function () {
smartgit.pull(paths.temp);
});
});
describe("remote", function () {
it("should error for noGit", function () {
smartgit.remote.add(paths.noGit, null, null);
});
it("should error for no remote name", function () {
smartgit.remote.add(paths.temp, null, null);
});
it("should error for no remote link", function () {
smartgit.remote.add(paths.temp, "origin", null);
});
it("should add a remote", function () {
smartgit.remote.add(paths.temp, "origin2", "https://github.com/pushrocks/somerepo");
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFFdEIsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQ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C;IAElB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,EAAC;IAEhB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -1,51 +1,85 @@
import { tap, expect } from '@push.rocks/tapbundle'; import "typings-test";
import * as smartgit from '../ts/index.js'; import beautylog = require("beautylog");
let shelljs = require("shelljs");
import path = require("path");
import "should"
import * as smartpath from '@push.rocks/smartpath'; 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/")
}
let testSmartgitInstance: smartgit.Smartgit; describe("smartgit",function(){
const packageDir = path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../'); describe(".clone",function(){
const testRepoDir = path.join(packageDir, './.nogit/testrepo'); it("should clone a repository using ssh and sshkey",function(done){
const testRepoDirSmartfile = path.join(packageDir, './.nogit/pushrocks_smartfile'); this.timeout(40000);
smartgit.clone({
tap.test('should create a valid smartgit instance', async () => { from:"git@gitlab.com:sandboxzone/sandbox-testrepo.git",
testSmartgitInstance = new smartgit.Smartgit(); to:paths.temp
await testSmartgitInstance.init(); }).then(function(){
expect(testSmartgitInstance).toBeInstanceOf(smartgit.Smartgit); done();
}); });
});
tap.test('should create a new repo at .nogit', async () => { it("should clone a repository using https",function(done){
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir); this.timeout(40000);
}); smartgit.clone({
from:"https://gitlab.com/sandboxzone/sandbox-testrepo.git",
tap.test('should clone a repo', async () => { to:paths.temp2
const gitRepo = await testSmartgitInstance.createRepoByClone( }).then(function(){
'https://gitlab.com/push.rocks/smartfile.git', done();
testRepoDirSmartfile });
); });
}); });
describe(".add",function(){
tap.test('should open a repo', async () => { it("should error for noGit",function(){
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir); smartgit.add.addAll(paths.noGit);
const diff = await gitRepo.getUncommittedDiff([ })
'pnpm-lock.yaml', it("should add a file to an existing repository",function(){
]); shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`)
console.log(diff); smartgit.add.addAll(paths.temp);
}); })
});
tap.test('should get the diff to HEAD', async () => { describe("commit",function(){
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir); it("should error for noGit",function(){
const diff = await gitRepo.getUncommittedDiff([ smartgit.commit(paths.noGit,"some commit message");
'pnpm-lock.yaml', })
]); it("should commit a new file to an existing repository",function(){
console.log(diff); smartgit.commit(paths.temp,"added a new file");
}); })
});
tap.test('should print all commit messages', async () => { describe("init",function(){
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir); it("should error for noGit",function(){
const commitMessages = await gitRepo.getAllCommitMessages(); smartgit.init(paths.noGit);
console.log(commitMessages); });
}); it("should init a new git",function(){
smartgit.init(paths.temp3);
await tap.start(); })
});
describe("pull",function(){
this.timeout(40000);
it("should error for noGit",function(){
smartgit.pull(paths.noGit);
});
it("should pull from origin",function(){
smartgit.pull(paths.temp);
})
});
describe("remote",function(){
it("should error for noGit",function(){
smartgit.remote.add(paths.noGit,null,null);
});
it("should error for no remote name",function(){
smartgit.remote.add(paths.temp,null,null);
});
it("should error for no remote link",function(){
smartgit.remote.add(paths.temp,"origin",null);
});
it("should add a remote",function(){
smartgit.remote.add(paths.temp,"origin2","https://github.com/pushrocks/somerepo");
});
});
});

View File

@ -1,8 +0,0 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartgit',
version: '3.1.1',
description: 'A smart wrapper for nodegit that simplifies Git operations in Node.js.'
}

View File

@ -1,2 +1,10 @@
export * from './smartgit.classes.gitrepo.js'; import plugins = require("./smartgit.plugins");
export * from './smartgit.classes.smartgit.js';
export {add} from "./smartgit.add";
export {clone} from "./smartgit.clone";
export {commit} from "./smartgit.commit";
export {init} from "./smartgit.init";
export {pull} from "./smartgit.pull";
export {push} from "./smartgit.push";
export {remote} from "./smartgit.remote";
export {status} from "./smartgit.status";

2
ts/postinstall.ts Normal file
View File

@ -0,0 +1,2 @@
let shelljs = require("shelljs");
import beautylog = require("beautylog");

19
ts/smartgit.add.ts Normal file
View File

@ -0,0 +1,19 @@
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
let addAll = (dirPathArg:string) => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.add expects a valid git directory!");
done.reject();
return done.promise;
};
// if everything is ok proceed
plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`);
done.resolve(dirPathArg);
return done.promise;
};
export let add = {
addAll: addAll
}

4
ts/smartgit.check.ts Normal file
View File

@ -0,0 +1,4 @@
import plugins = require("./smartgit.plugins");
export = function(repoArg) {
return true;
};

View File

@ -1,228 +0,0 @@
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 {
// 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 existence 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,
});
}
/**
* 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;
}
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,
});
}
/**
* Get the diff of the current uncommitted changes while excluding specified files
*/
public async getUncommittedDiff(excludeFiles: string[] = []): Promise<string[]> {
const statusMatrix = await plugins.isomorphicGit.statusMatrix({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
});
const diffs: string[] = [];
for (const row of statusMatrix) {
const [filepath, head, workdir] = row;
if (excludeFiles.includes(filepath)) {
continue; // Skip excluded files
}
let headContent = '';
let workdirContent = '';
// Handle modified files
if (head !== 0 && workdir !== 0 && head !== workdir) {
headContent = await plugins.isomorphicGit
.readBlob({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
oid: await plugins.isomorphicGit.resolveRef({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
ref: 'HEAD',
}),
filepath,
})
.then((result) => new TextDecoder().decode(result.blob));
workdirContent = await this.smartgitRef.envDeps.fs.promises.readFile(
plugins.path.join(this.repoDir, filepath),
'utf8'
);
}
// Handle added files
if (head === 0 && workdir !== 0) {
workdirContent = await this.smartgitRef.envDeps.fs.promises.readFile(
plugins.path.join(this.repoDir, filepath),
'utf8'
);
}
// Handle deleted files
if (head !== 0 && workdir === 0) {
headContent = await plugins.isomorphicGit
.readBlob({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
oid: await plugins.isomorphicGit.resolveRef({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
ref: 'HEAD',
}),
filepath,
})
.then((result) => new TextDecoder().decode(result.blob));
}
if (headContent || workdirContent) {
const diff = plugins.diff.createTwoFilesPatch(
filepath,
filepath,
headContent,
workdirContent
);
diffs.push(diff);
}
}
return diffs;
}
/**
* Get all commit messages with their dates and package.json version at each commit
*/
public async getAllCommitMessages(): Promise<
{ date: string; version: string; message: string }[]
> {
const commits = await plugins.isomorphicGit.log({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
});
const results = [];
for (const commit of commits) {
let version = 'unknown';
try {
const packageJsonBlob = await plugins.isomorphicGit.readBlob({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
oid: commit.oid,
filepath: 'package.json',
});
const packageJson = JSON.parse(new TextDecoder().decode(packageJsonBlob.blob));
version = packageJson.version;
} catch (error) {
// If package.json does not exist or any error occurs, leave version as 'unknown'
}
results.push({
date: new plugins.smarttime.ExtendedDate(commit.commit.committer.timestamp * 1000).exportToHyphedSortableDate(),
version: version,
message: commit.commit.message,
});
}
return results;
}
}

View File

@ -1,40 +0,0 @@
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;
}
}

16
ts/smartgit.clone.ts Normal file
View File

@ -0,0 +1,16 @@
import plugins = require("./smartgit.plugins");
import SmartgitCheck = require("./smartgit.check");
export let clone = (optionsArg: {
from: string,
to: string,
key?: string,
keyPath?: string,
keyPassphrase?: string
}) => {
let done = plugins.Q.defer();
plugins.smartfile.fs.ensureDir(optionsArg.to);
plugins.shelljs.exec(`git clone ${optionsArg.from} ${optionsArg.to}`);
done.resolve();
return done.promise;
};

15
ts/smartgit.commit.ts Normal file
View File

@ -0,0 +1,15 @@
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
export let commit = (dirPathArg:string,commitMessage:string) => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.commit expects a valid git directory");
done.reject();
return done.promise;
};
// if everything is all right proceed
plugins.shelljs.exec(`(cd ${dirPathArg} && git commit -m "${commitMessage}")`);
done.resolve();
return done.promise;
};

12
ts/smartgit.helpers.ts Normal file
View File

@ -0,0 +1,12 @@
import * as plugins from "./smartgit.plugins";
export let isGitDirectory = (dirPathArg):boolean => {
try {
return plugins.smartfile.fs.isDirectory(
plugins.path.join(dirPathArg,".git")
);
}
catch(err){
return false;
}
}

13
ts/smartgit.init.ts Normal file
View File

@ -0,0 +1,13 @@
import plugins = require("./smartgit.plugins");
export let init = (dirPathArg:string) => {
let done = plugins.Q.defer();
if (typeof dirPathArg == "undefined") { //lets check if a destination is defined...
plugins.beautylog.error("smartgit.init requires an absolute directory path!");
return;
};
plugins.smartfile.fs.ensureDir(dirPathArg);
plugins.shelljs.exec(`(cd ${dirPathArg} && git init)`);
done.resolve(dirPathArg);
return done.promise;
};

View File

@ -1,19 +1,9 @@
// node native import "typings-global";
import * as path from 'path';
export { path }; export import path = require("path");
export import beautylog = require("beautylog");
import * as smartenv from '@push.rocks/smartenv'; export let Q = require("q");
import * as smartfile from '@push.rocks/smartfile'; export let shelljs = require("shelljs");
import * as smartpath from '@push.rocks/smartpath'; export import smartfile = require("smartfile");
import * as smartpromise from '@push.rocks/smartpromise'; export import smartpath = require("smartpath");
import * as smartstring from '@push.rocks/smartstring'; export import smartstring = require("smartstring");
import * as smarttime from '@push.rocks/smarttime';
export { smartenv, smartfile, smartpath, smartpromise, smartstring, smarttime };
// third party
import * as diff from 'diff';
import isomorphicGit from 'isomorphic-git';
export { diff, isomorphicGit };

15
ts/smartgit.pull.ts Normal file
View File

@ -0,0 +1,15 @@
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
export let pull = (dirPathArg:string,sourceArg:string = "", branchArg:string = "") => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.pull expects a valid git directory");
done.reject();
return done.promise;
};
// if everything is allright proceed
plugins.shelljs.exec(`(cd ${dirPathArg} && git pull ${sourceArg} ${branchArg})`);
done.resolve(dirPathArg);
return done.promise;
};

15
ts/smartgit.push.ts Normal file
View File

@ -0,0 +1,15 @@
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
export let push = (dirPathArg:string, sourceArg:string = "", branchArg:string = "") => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.push expects a valid git directory");
done.reject();
return done.promise;
}
// if everything seems allright proceed
plugins.shelljs.exec(`(cd ${dirPathArg} && git status)`);
done.resolve();
return done.promise;
};

60
ts/smartgit.remote.ts Normal file
View File

@ -0,0 +1,60 @@
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
let add = (dirPathArg,remoteNameArg:string, remoteLinkArg:string) => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.remote.add expects a valid git directory");
done.reject();
return done.promise;
};
if(!remoteNameArg) {
plugins.beautylog.error("smartgit.remote.add expects a valid remote name");
done.reject();
return done.promise;
};
if(!remoteLinkArg) {
plugins.beautylog.error("smartgit.remote.add expects a valid remote link");
done.reject();
return done.promise;
};
// if everything is all right proceed
plugins.shelljs.exec(`cd ${dirPathArg} && git remote add ${remoteNameArg} ${remoteLinkArg}`);
remote.list(dirPathArg);
done.resolve();
return done.promise;
};
let check = (dirPathArg:string, remoteNameArg:string, remoteLinkArg) => {
}
let list = (dirPathArg) => {
let done = plugins.Q.defer();
let remotes = {};
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.remote.list expects a valid git directory");
done.reject();
return done.promise;
};
// if everything is all right proceed
plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`).stdout;
done.resolve(remotes);
return done.promise;
};
let remove = (dirPathArg:string) => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.remote.remove expects a valid git directory");
done.reject();
return done.promise;
};
// if everything is all right
}
export let remote = {
add: add,
list: list,
remove: remove
}

15
ts/smartgit.status.ts Normal file
View File

@ -0,0 +1,15 @@
import * as plugins from "./smartgit.plugins";
import * as helpers from "./smartgit.helpers";
export let status = (dirPathArg:string) => {
let done = plugins.Q.defer();
if(!helpers.isGitDirectory(dirPathArg)){
plugins.beautylog.error("smartgit.status expects a valid git directory");
done.reject();
return done.promise;
}
// if everything seems allright proceed
plugins.shelljs.exec(`(cd ${dirPathArg} && git status)`);
done.resolve();
return done.promise;
};

View File

@ -1,14 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}