Compare commits

...

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

39 changed files with 7860 additions and 321 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 @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

27
.gitignore vendored
View File

@ -1,13 +1,20 @@
node_modules/
.settings/
.idea/
test/temp/
.nogit/
# artifacts
coverage/
docs/
public/
pages/
#npm devug
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,15 +0,0 @@
language: node_js
node_js:
- 4
- stable
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,15 +0,0 @@
# smartgit is an easy wrapper for nodegit
an easy wrapper for nodegit
### Buildstatus/Dependencies
[![Build Status](https://travis-ci.org/pushrocks/smartgit.svg?branch=master)](https://travis-ci.org/pushrocks/smartgit)
[![devDependency Status](https://david-dm.org/pushrocks/smartgit/dev-status.svg)](https://david-dm.org/pushrocks/smartgit#info=devDependencies)
### Usage
This npm package comes with everything you need to start your own gulp plugin.
Features:
* easily cone a git repo
* easily create a new git repo
* easily add all changes and make a new commit

63
changelog.md Normal file
View File

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

14
dist/index.js vendored
View File

@ -1,14 +0,0 @@
/// <reference path="./typings/main.d.ts" />
"use strict";
var SmartgitCheck = require("./smartgit.check");
var SmartgitClone = require("./smartgit.clone");
var SmartgitCommit = require("./smartgit.commit");
var SmartgitInit = require("./smartgit.init");
var smartgit = {};
smartgit.clone = SmartgitClone;
smartgit.commit = SmartgitCommit;
smartgit.check = SmartgitCheck;
smartgit.init = SmartgitInit;
module.exports = smartgit;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFHNUMsSUFBTyxhQUFhLFdBQVcsa0JBQWtCLENBQUMsQ0FBQztBQUNuRCxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBQ25ELElBQU8sY0FBYyxXQUFXLG1CQUFtQixDQUFDLENBQUM7QUFDckQsSUFBTyxZQUFZLFdBQVcsaUJBQWlCLENBQUMsQ0FBQztBQUVqRCxJQUFJLFFBQVEsR0FBTyxFQUFFLENBQUM7QUFDdEIsUUFBUSxDQUFDLEtBQUssR0FBRyxhQUFhLENBQUM7QUFDL0IsUUFBUSxDQUFDLE1BQU0sR0FBRyxjQUFjLENBQUM7QUFDakMsUUFBUSxDQUFDLEtBQUssR0FBRyxhQUFhLENBQUM7QUFDL0IsUUFBUSxDQUFDLElBQUksR0FBRyxZQUFZLENBQUM7QUFHN0IsTUFBTSxDQUFDLE9BQU8sR0FBRyxRQUFRLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRnaXQucGx1Z2luc1wiKTtcbmltcG9ydCBTbWFydGdpdENoZWNrID0gcmVxdWlyZShcIi4vc21hcnRnaXQuY2hlY2tcIik7XG5pbXBvcnQgU21hcnRnaXRDbG9uZSA9IHJlcXVpcmUoXCIuL3NtYXJ0Z2l0LmNsb25lXCIpO1xuaW1wb3J0IFNtYXJ0Z2l0Q29tbWl0ID0gcmVxdWlyZShcIi4vc21hcnRnaXQuY29tbWl0XCIpO1xuaW1wb3J0IFNtYXJ0Z2l0SW5pdCA9IHJlcXVpcmUoXCIuL3NtYXJ0Z2l0LmluaXRcIik7XG5cbnZhciBzbWFydGdpdDphbnkgPSB7fTtcbnNtYXJ0Z2l0LmNsb25lID0gU21hcnRnaXRDbG9uZTtcbnNtYXJ0Z2l0LmNvbW1pdCA9IFNtYXJ0Z2l0Q29tbWl0O1xuc21hcnRnaXQuY2hlY2sgPSBTbWFydGdpdENoZWNrO1xuc21hcnRnaXQuaW5pdCA9IFNtYXJ0Z2l0SW5pdDtcblxuXG5tb2R1bGUuZXhwb3J0cyA9IHNtYXJ0Z2l0O1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

View File

@ -1,3 +0,0 @@
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzbWFydGdpdC5hZGQuanMiLCJzb3VyY2VzQ29udGVudCI6W10sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

View File

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

View File

@ -1,22 +0,0 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./smartgit.plugins");
var SmartgitCheck = require("./smartgit.check");
module.exports = 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);
SmartgitCheck(cloneRepository);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNsb25lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDNUMsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUMvQyxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBRW5ELGlCQUFTLFVBQVMsT0FBTztJQUVyQix5QkFBeUI7SUFDekIsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLElBQUksSUFBSSxXQUFXLElBQUksT0FBTyxDQUFDLEVBQUUsSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQzNELE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLGdCQUFnQixDQUFDLElBQUksR0FBRyxnRUFBZ0UsQ0FBQyxDQUFDO1FBQ2xILE1BQU0sQ0FBQztJQUNYLENBQUM7SUFFRCwwQkFBMEI7SUFDMUIsRUFBRSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDM0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsK0JBQStCLEdBQUcsT0FBTyxDQUFDLEVBQUUsR0FBRyxtQkFBbUIsQ0FBQyxDQUFDO1FBQzVGLE1BQU0sQ0FBQztJQUNYLENBQUM7SUFHRCxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3JELElBQUksWUFBWSxHQUFPLEVBQUUsQ0FBQztJQUMxQixJQUFJLGVBQWUsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsSUFBSSxFQUFFLE9BQU8sQ0FBQyxFQUFFLEVBQUUsWUFBWSxDQUFDLENBQUM7SUFDcEYsYUFBYSxDQUFDLGVBQWUsQ0FBQyxDQUFDO0FBQ25DLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydGdpdC5jbG9uZS5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRnaXQucGx1Z2luc1wiKTtcbmltcG9ydCBTbWFydGdpdENoZWNrID0gcmVxdWlyZShcIi4vc21hcnRnaXQuY2hlY2tcIik7XG5cbmV4cG9ydCA9IGZ1bmN0aW9uKG9wdGlvbnMpe1xuXG4gICAgLyoqKioqIFVSTCBDaGVja3MgKioqKioqL1xuICAgIGlmIChvcHRpb25zLmZyb20gPT0gXCJ1bmRlZmluZWRcIiB8fCBvcHRpb25zLnRvID09IFwidW5kZWZpbmVkXCIpIHtcbiAgICAgICAgcGx1Z2lucy5iZWF1dHlsb2cuZXJyb3IoXCJzbWFydGdpdC5jbG9uZVwiLmJsdWUgKyBcIiA6IFNvbWV0aGluZyBpcyBzdHJhbmdlIGFib3V0IHRoZSB3YXkgeW91IGludm9rZWQgdGhlIGZ1bmN0aW9uXCIpO1xuICAgICAgICByZXR1cm47XG4gICAgfVxuXG4gICAgLyoqKioqIFBhdGggQ2hlY2tzICoqKioqKi9cbiAgICBpZiAoIS9eXFwvLiovLnRlc3Qob3B0aW9ucy50bykpeyAvL2NoZWNrIHdldGhlciBwYXRoIGlzIGFic29sdXRlXG4gICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmVycm9yKFwiSXQgc2VlbXMgdGhhdCB0aGUgZ2l2ZW4gcGF0aCBcIiArIG9wdGlvbnMudG8gKyBcIiBpcyBub3QgYWJzb2x1dGUuXCIpO1xuICAgICAgICByZXR1cm47XG4gICAgfVxuXG5cbiAgICBwbHVnaW5zLmJlYXV0eWxvZy5sb2coXCJOb3cgY2xvbmluZyBcIiArIG9wdGlvbnMuZnJvbSk7XG4gICAgdmFyIGNsb25lT3B0aW9uczphbnkgPSB7fTtcbiAgICB2YXIgY2xvbmVSZXBvc2l0b3J5ID0gcGx1Z2lucy5ub2RlZ2l0LkNsb25lKG9wdGlvbnMuZnJvbSwgb3B0aW9ucy50bywgY2xvbmVPcHRpb25zKTtcbiAgICBTbWFydGdpdENoZWNrKGNsb25lUmVwb3NpdG9yeSk7XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

View File

@ -1,10 +0,0 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./smartgit.plugins");
module.exports = function (pathArg, commitMessage) {
var result = plugins.nodegit.index.addByPath(pathArg);
if (result == 0) {
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNvbW1pdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsNENBQTRDO0FBQzVDLElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFFL0MsaUJBQVMsVUFBUyxPQUFjLEVBQUMsYUFBb0I7SUFDakQsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3RELEVBQUUsQ0FBQyxDQUFDLE1BQU0sSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBRWxCLENBQUM7QUFDTCxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRnaXQuY29tbWl0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydGdpdC5wbHVnaW5zXCIpO1xuXG5leHBvcnQgPSBmdW5jdGlvbihwYXRoQXJnOnN0cmluZyxjb21taXRNZXNzYWdlOnN0cmluZykge1xuICAgIHZhciByZXN1bHQgPSBwbHVnaW5zLm5vZGVnaXQuaW5kZXguYWRkQnlQYXRoKHBhdGhBcmcpO1xuICAgIGlmIChyZXN1bHQgPT0gMCkge1xuICAgICAgICBcbiAgICB9XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

17
dist/smartgit.init.js vendored
View File

@ -1,17 +0,0 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./smartgit.plugins");
module.exports = 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.
});
};
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmluaXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBRS9DLGlCQUFTO0lBQ0wsSUFBSSxPQUFPLEdBQUcsVUFBUyxJQUF5QjtRQUF6QixvQkFBeUIsR0FBekIsa0JBQXlCO1FBQzVDLEVBQUUsQ0FBQyxDQUFDLElBQUksSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQ3RCLE1BQU0sQ0FBQyxDQUFDLHFDQUFxQztRQUNqRCxDQUFDO1FBQ0QsSUFBSSxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMseUJBQXlCO1FBQ3pDLE9BQU8sQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsTUFBTSxDQUFDLENBQUMsSUFBSSxDQUFDLFVBQVUsSUFBSTtZQUM3RCwrQkFBK0I7UUFDbkMsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUM7QUFDTixDQUFDLENBQUEiLCJmaWxlIjoic21hcnRnaXQuaW5pdC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRnaXQucGx1Z2luc1wiKTtcblxuZXhwb3J0ID0gZnVuY3Rpb24oKXtcbiAgICB2YXIgZ2l0aW5pdCA9IGZ1bmN0aW9uKGRlc3Q6c3RyaW5nID0gXCJ1bmRlZmluZWRcIikge1xuICAgICAgICBpZiAoZGVzdCA9PSBcInVuZGVmaW5lZFwiKSB7IC8vbGV0cyBjaGVjayBpZiBhIGRlc3RpbmF0aW9uIGlzIGRlZmluZWQuLi5cbiAgICAgICAgICAgIHJldHVybjsgLy8gLi4uYW5kIHJldHVybiBmdW5jdGlvbiBoZXJlIGlmIG5vdFxuICAgICAgICB9XG4gICAgICAgIHZhciBpc0JhcmUgPSAwOyAvL2xldHMgY3JlYXRlIGEgc3ViZm9sZGVyXG4gICAgICAgIHBsdWdpbnMubm9kZWdpdC5SZXBvc2l0b3J5LmluaXQoZGVzdCwgaXNCYXJlKS50aGVuKGZ1bmN0aW9uIChyZXBvKSB7XG4gICAgICAgICAgICAvLyBkbyBzb21ldGhpbmcgd2l0aCByZXBvIGhlcmUuXG4gICAgICAgIH0pO1xuICAgIH07XG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

View File

@ -1,3 +0,0 @@
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzbWFydGdpdC5pbnRlcmZhY2VzLmpzIiwic291cmNlc0NvbnRlbnQiOltdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

View File

@ -1,8 +0,0 @@
/// <reference path="./typings/main.d.ts" />
"use strict";
exports.path = require("path");
exports.beautylog = require("beautylog");
exports.nodegit = require("nodegit");
exports.Q = require("q");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDOztBQUVqQyxZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDN0IsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydGdpdC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5leHBvcnQgbGV0IHBhdGggPSByZXF1aXJlKFwicGF0aFwiKTtcbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgbm9kZWdpdCA9IHJlcXVpcmUoXCJub2RlZ2l0XCIpO1xuZXhwb3J0IGxldCBRID0gcmVxdWlyZShcInFcIik7XG5cblxuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

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;

31
npmextra.json Normal file
View File

@ -0,0 +1,31 @@
{
"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"
}
}

View File

@ -1,33 +1,69 @@
{
"name": "smartgit",
"version": "0.0.7",
"description": "an easy wrapper for nodegit",
"main": "dist/index.js",
"name": "@push.rocks/smartgit",
"version": "3.1.1",
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "https://github.com/pushrocks/smartgit.git"
"url": "https://code.foss.global/push.rocks/smartgit.git"
},
"keywords": [
"json",
"jade",
"template"
"git",
"nodegit",
"version control",
"git wrapper",
"programming",
"development",
"code management",
"repository management",
"git operations"
],
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
"license": "MIT",
"bugs": {
"url": "https://github.com/pushrocks/smartgit/issues"
"url": "https://gitlab.com/pushrocks/smartgit/issues"
},
"homepage": "https://github.com/pushrocks/smartgit",
"homepage": "https://code.foss.global/push.rocks/smartgit",
"dependencies": {
"beautylog": "3.1.2",
"nodegit": "0.12.1",
"q": "1.4.1"
"@push.rocks/smartenv": "^5.0.12",
"@push.rocks/smartfile": "^11.0.20",
"@push.rocks/smartpath": "^5.0.18",
"@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smartshell": "^3.0.5",
"@push.rocks/smartstring": "^4.0.15",
"@push.rocks/smarttime": "^4.0.6",
"@types/diff": "^5.2.1",
"@types/minimatch": "^5.1.2",
"diff": "^5.2.0",
"isomorphic-git": "^1.25.10"
},
"devDependencies": {
"npmts": "3.6.10",
"should": "^8.3.0"
}
"@git.zone/tsbuild": "^2.1.80",
"@git.zone/tsrun": "^1.2.44",
"@git.zone/tstest": "^1.0.90",
"@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 Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

137
readme.md Normal file
View File

@ -0,0 +1,137 @@
# @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.

1
test

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

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

51
test/test.ts Normal file
View File

@ -0,0 +1,51 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as smartgit from '../ts/index.js';
import * as smartpath from '@push.rocks/smartpath';
import * as path from 'path';
let testSmartgitInstance: smartgit.Smartgit;
const packageDir = path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
const testRepoDir = path.join(packageDir, './.nogit/testrepo');
const testRepoDirSmartfile = path.join(packageDir, './.nogit/pushrocks_smartfile');
tap.test('should create a valid smartgit instance', async () => {
testSmartgitInstance = new smartgit.Smartgit();
await testSmartgitInstance.init();
expect(testSmartgitInstance).toBeInstanceOf(smartgit.Smartgit);
});
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.test('should open a repo', async () => {
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
const diff = await gitRepo.getUncommittedDiff([
'pnpm-lock.yaml',
]);
console.log(diff);
});
tap.test('should get the diff to HEAD', async () => {
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
const diff = await gitRepo.getUncommittedDiff([
'pnpm-lock.yaml',
]);
console.log(diff);
});
tap.test('should print all commit messages', async () => {
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
const commitMessages = await gitRepo.getAllCommitMessages();
console.log(commitMessages);
});
await tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* 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,16 +1,2 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
import SmartgitCheck = require("./smartgit.check");
import SmartgitClone = require("./smartgit.clone");
import SmartgitCommit = require("./smartgit.commit");
import SmartgitInit = require("./smartgit.init");
var smartgit:any = {};
smartgit.clone = SmartgitClone;
smartgit.commit = SmartgitCommit;
smartgit.check = SmartgitCheck;
smartgit.init = SmartgitInit;
module.exports = smartgit;
export * from './smartgit.classes.gitrepo.js';
export * from './smartgit.classes.smartgit.js';

View File

View File

@ -1,5 +0,0 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
export = function(repoArg) {
return true;
};

View File

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

@ -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,24 +0,0 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
import SmartgitCheck = require("./smartgit.check");
export = 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)){ //check wether path is absolute
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
return;
}
plugins.beautylog.log("Now cloning " + options.from);
var cloneOptions:any = {};
var cloneRepository = plugins.nodegit.Clone(options.from, options.to, cloneOptions);
SmartgitCheck(cloneRepository);
};

View File

@ -1,9 +0,0 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
export = function(pathArg:string,commitMessage:string) {
var result = plugins.nodegit.index.addByPath(pathArg);
if (result == 0) {
}
};

View File

@ -1,14 +0,0 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartgit.plugins");
export = function(){
var gitinit = function(dest:string = "undefined") {
if (dest == "undefined") { //lets check if a destination is defined...
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.
});
};
}

View File

@ -1,8 +1,19 @@
/// <reference path="./typings/main.d.ts" />
// node native
import * as path from 'path';
export let path = require("path");
export let beautylog = require("beautylog");
export let nodegit = require("nodegit");
export let Q = require("q");
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';
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 };

View File

@ -1,7 +0,0 @@
{
"ambientDependencies": {
"colors": "registry:dt/colors#0.6.0-1+20160317120654",
"mocha": "registry:dt/mocha#2.2.5+20160317120654",
"node": "registry:dt/node#4.0.0+20160330064709"
}
}

14
tsconfig.json Normal file
View File

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