Compare commits
70 Commits
Author | SHA1 | Date | |
---|---|---|---|
5ba6c5370e | |||
c6e3a1caa3 | |||
a92275088b | |||
2b246502f5 | |||
81b2b225a3 | |||
9a2d5afc04 | |||
6404c8342a | |||
b14ae1d8a6 | |||
753bc49c4e | |||
a5dae9b3a3 | |||
af909047ae | |||
11cbe93b4b | |||
e8c3d3c44f | |||
a2485560b3 | |||
7aa83ac730 | |||
141af9843f | |||
71e84e79b1 | |||
aefcf56f0e | |||
ace668bfc1 | |||
f2949c5f21 | |||
6ebb7cec81 | |||
c64de19815 | |||
26d4753ddf | |||
6d5b9f3553 | |||
8dd8bd0be1 | |||
0bd91c2bda | |||
6ef3e6e6f5 | |||
93709f920e | |||
75fa530f73 | |||
f5617d9d45 | |||
b46d1e19a7 | |||
c8d173807d | |||
5944c7e96f | |||
39ea160fdf | |||
91ca5e53f1 | |||
778267bb36 | |||
61407e4854 | |||
2771413723 | |||
b83752a98a | |||
48f71ed1c2 | |||
54ed2f97b8 | |||
92198a75c9 | |||
f82a34b1ea | |||
c3b68fa0fc | |||
1af7afd723 | |||
66e45154e3 | |||
dcc58a312e | |||
90f57bee1a | |||
98d1f8aea2 | |||
1f542367e6 | |||
201a5014ed | |||
6cc245ae7e | |||
1377fb6eb7 | |||
daf8c80513 | |||
46fce49356 | |||
8616613a95 | |||
352e4d8e96 | |||
c2105ce78f | |||
2864fc5507 | |||
fea523ff5c | |||
872f2354c5 | |||
ff0318534f | |||
e103074684 | |||
f72beabd90 | |||
958a625633 | |||
871fd55c5c | |||
07fd9b9fa7 | |||
62d6a8d685 | |||
047cf02e6a | |||
69127cacdd |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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
|
23
.gitignore
vendored
23
.gitignore
vendored
@@ -1,13 +1,20 @@
|
||||
node_modules/
|
||||
test/temp/
|
||||
test/temp2/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
#npm debug
|
||||
npm-debug.log
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
ts/typings/
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@@ -1,49 +0,0 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
|
||||
before_script:
|
||||
- npmci prepare ssh
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
19
.travis.yml
19
.travis.yml
@@ -1,19 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 4
|
||||
- stable
|
||||
before_install:
|
||||
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install libstdc++-4.9-dev -y
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@lossless.digital
|
||||
api_key:
|
||||
secure: o/3H4keWRAvHZaJnUN9UX+hqu+prKGtBsOEWVIaRXUpf6nIHIDm9zlJrS5cv2VUseOZqLAOkzeGYPqlOJlxccy5frKEYMhtCY97BjKvUOf01roL82OGiahw5Bv04NcaBoSepCliyyXihlgZO/5tSoR1seY4ycul2qWLktaEmh8HcTPjem8gB49Svpfk8yPKLpq6cv/sSakt2X24Cq+vfdxYiz7GcgBfv3EVAndUmQ9KMQfkSbq8XgYEZKrLi5kdpXX0y1LRdsbn2rwuMwLOmefCenmQSuBCbYmbOxPgVHHHjVm9To/rhx8YHBCcZSH9go2pdDLwrd7VPOCK+vMHCz/rlASwVM/BGr+aJHCFLAyovrIU7cvbbjLPOUjto6xY2XckMmDBD1YDxYnAJAON1QrdXE9hVVRfMNfaC2leFAwhla1WMok5DcEv+/Q9cUXQCBGQHtBhkhmCCt54ERLFnjXCDZr1icR/0lhtQY54hin5jSHqnU2hTZtTpQX7sF0yZM2sbhTBpV5FTDAGH/ohNWSEnTwAXmL9iwZCTvtWUbBeOUSDRj8BLS54uiaIcIVytNY0p2PdnhwJAWO+4FGjSOT+RuK8RiKzyVXjPiX8TCzaOqBFs947m8SSNMSt6zyqOI27gOSzU7szgsKY769Fl+X9sdzFXaSa72rj4EdvgiBA=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/smartgit
|
||||
notifications:
|
||||
slack:
|
||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
68
README.md
68
README.md
@@ -1,68 +0,0 @@
|
||||
# smartgit
|
||||
smart git wrapper for node.
|
||||
|
||||
smartgit expects git to be installed on target machine.
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartgit)
|
||||
[](https://gitlab.com/pushrocks/smartgit)
|
||||
[](https://github.com/pushrocks/smartgit)
|
||||
[](https://pushrocks.gitlab.io/smartgit/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartgit/commits/master)
|
||||
[](https://david-dm.org/pushrocks/smartgit)
|
||||
[](https://www.bithound.io/github/pushrocks/smartgit/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartgit)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
We recommend the use of TypeScript for best in class intellisense
|
||||
|
||||
```javascript
|
||||
// import smartgit:
|
||||
import { GitRepo } from 'smartgit'
|
||||
|
||||
// Initialize smartgit:
|
||||
// -- note: there are 3 ways to initialize smartgit
|
||||
// -- -- 1. with a existing Git repo
|
||||
// -- -- 2. with a cloned Git repo
|
||||
// -- -- 3. with a new Git repo
|
||||
|
||||
// -- 1. existing Git Repo:
|
||||
let myExistingGitRepo = new GitRepo('/path/to/existing/git/repo/')
|
||||
|
||||
// -- 2. cloned Git Repo:
|
||||
let myClonedGitRepo: GitRepo
|
||||
smartgit.createRepoFromClone('git@github.com:username/reponame.git')
|
||||
.then(gitRepo => { // non blocking
|
||||
myClonedGitRepo = gitRepo
|
||||
})
|
||||
|
||||
// -- 3. new Git Repo
|
||||
let myNewGitRepo: GitRepo
|
||||
smartgit.createRepoFromInit('/path/to/new/folder') // smartgit will create any new folder, be careful
|
||||
.then(gitRepo => { // non blocking
|
||||
myNewGitRepo = gitRepo
|
||||
})
|
||||
|
||||
// Using smartgit instance
|
||||
// -- most used actions
|
||||
// -- all actions return promises, so make sure to use promise chaining for any dependent tasks
|
||||
myExistingGitRepo.addAll() // returns promise, stages all changed files
|
||||
myExistingGitRepo.add(['relative/path/to/file.txt','another/file2.txt']) // returns promise, stages specific files
|
||||
myExistingGitRepo.commit('my commit message') // returns promise, commits staged files
|
||||
myExistingGitRepo.status() // returns promise
|
||||
.then(status => { // Use TypeScript for status type information
|
||||
|
||||
})
|
||||
myExistingGitRepo.check() // returns promise, checks repo health
|
||||
myExistingGitRepo.remoteAdd('git@github.com:username/reponame.git')
|
||||
```
|
||||
|
||||
Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment
|
||||
|
||||
[](https://push.rocks)
|
76
changelog.md
Normal file
76
changelog.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-01-04 - 3.2.0 - feat(core)
|
||||
Enhanced error handling, type safety, and documentation
|
||||
|
||||
- Add comprehensive error handling with try/catch blocks and meaningful error messages
|
||||
- Improve type safety with proper IEnvDeps interface replacing 'any' types
|
||||
- Add complete JSDoc documentation for all classes and methods
|
||||
- Add return type annotations for better TypeScript support
|
||||
- Add ensureInitialized() validation method
|
||||
- Fix missing return statement in createRepoByClone() method
|
||||
- Remove deprecated @types/minimatch dependency
|
||||
- Complete readme rewrite with modern styling, accurate documentation, and proper API examples
|
||||
- Update license from LICENSE to license.md following project guidelines
|
||||
|
||||
## 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
|
12
dist/index.d.ts
vendored
12
dist/index.d.ts
vendored
@@ -1,12 +0,0 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
import { GitRepo } from './smartgit.classes.gitrepo';
|
||||
export { GitRepo };
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise<GitRepo>;
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export declare let createRepoFromInit: (destinationDirArg: string) => q.Promise<GitRepo>;
|
28
dist/index.js
vendored
28
dist/index.js
vendored
@@ -1,28 +0,0 @@
|
||||
"use strict";
|
||||
const q = require("q");
|
||||
const plugins = require("./smartgit.plugins");
|
||||
const smartgit_classes_gitrepo_1 = require("./smartgit.classes.gitrepo");
|
||||
exports.GitRepo = smartgit_classes_gitrepo_1.GitRepo;
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
exports.createRepoFromClone = (fromArg, toArg) => {
|
||||
let done = q.defer();
|
||||
plugins.smartfile.fs.ensureDir(toArg);
|
||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
|
||||
let newRepo = new smartgit_classes_gitrepo_1.GitRepo(toArg);
|
||||
done.resolve(newRepo);
|
||||
return done.promise;
|
||||
};
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
exports.createRepoFromInit = (destinationDirArg) => {
|
||||
let done = q.defer();
|
||||
plugins.smartfile.fs.ensureDir(destinationDirArg);
|
||||
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`);
|
||||
let newRepo = new smartgit_classes_gitrepo_1.GitRepo(destinationDirArg);
|
||||
done.resolve(newRepo);
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsdUJBQXNCO0FBQ3RCLDhDQUErQztBQUUvQyx5RUFBb0Q7QUFFaEQscURBQU87QUFHWDs7R0FFRztBQUNRLFFBQUEsbUJBQW1CLEdBQUcsQ0FBQyxPQUFlLEVBQUUsS0FBYTtJQUM1RCxJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFXLENBQUE7SUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ3JDLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGFBQWEsT0FBTyxJQUFJLEtBQUssRUFBRSxDQUFDLENBQUE7SUFDckQsSUFBSSxPQUFPLEdBQUcsSUFBSSxrQ0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2hDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLGtCQUFrQixHQUFHLENBQUMsaUJBQXlCO0lBQ3RELElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQVcsQ0FBQTtJQUM3QixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUNqRCxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLGlCQUFpQixjQUFjLENBQUMsQ0FBQTtJQUMzRCxJQUFJLE9BQU8sR0FBRyxJQUFJLGtDQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtJQUM1QyxJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9
|
57
dist/smartgit.classes.gitrepo.d.ts
vendored
57
dist/smartgit.classes.gitrepo.d.ts
vendored
@@ -1,57 +0,0 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
/**
|
||||
* class GitRepo allows access to git directories from node
|
||||
*/
|
||||
export declare class GitRepo {
|
||||
repoBase: string;
|
||||
constructor(repoBaseArg: string);
|
||||
/**
|
||||
* checks if the Repo is valid
|
||||
*/
|
||||
check(): boolean;
|
||||
/**
|
||||
* stage all files in working directory
|
||||
*/
|
||||
addAll(dirPathArg: string): q.Promise<{}>;
|
||||
/**
|
||||
* add a remote to the GitRepo
|
||||
*/
|
||||
remoteAdd(remoteNameArg: string, remoteLinkArg: string): q.Promise<{}>;
|
||||
/**
|
||||
* list remotes for a Gip
|
||||
*/
|
||||
remoteList(): q.Promise<{}>;
|
||||
/**
|
||||
* remove remote
|
||||
*/
|
||||
remoteRemove(dirPathArg: string): q.Promise<{}>;
|
||||
/**
|
||||
* commit all files that are currently staged
|
||||
*/
|
||||
commit(commitMessage: string): q.Promise<{}>;
|
||||
/**
|
||||
* pull latest changes from remote
|
||||
*/
|
||||
pull(sourceArg?: string, branchArg?: string): q.Promise<{}>;
|
||||
/**
|
||||
* push new commits to remote
|
||||
*/
|
||||
push(remoteNameArg?: string, remoteBranchArg?: string): q.Promise<{}>;
|
||||
/**
|
||||
* sync
|
||||
*/
|
||||
sync(): void;
|
||||
/**
|
||||
* get the current status
|
||||
*/
|
||||
status(): q.Promise<{}>;
|
||||
}
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export declare let createRepoFromClone: (fromArg: string, toArg: string) => q.Promise<GitRepo>;
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export declare let createRepoFromInit: (destinationDirArg: string) => void;
|
141
dist/smartgit.classes.gitrepo.js
vendored
141
dist/smartgit.classes.gitrepo.js
vendored
File diff suppressed because one or more lines are too long
7
dist/smartgit.plugins.d.ts
vendored
7
dist/smartgit.plugins.d.ts
vendored
@@ -1,7 +0,0 @@
|
||||
import 'typings-global';
|
||||
export import path = require('path');
|
||||
export import beautylog = require('beautylog');
|
||||
export import shelljs = require('shelljs');
|
||||
export import smartfile = require('smartfile');
|
||||
export import smartpath = require('smartpath');
|
||||
export import smartstring = require('smartstring');
|
9
dist/smartgit.plugins.js
vendored
9
dist/smartgit.plugins.js
vendored
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.path = require("path");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.shelljs = require("shelljs");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartpath = require("smartpath");
|
||||
exports.smartstring = require("smartstring");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUNBQThDO0FBQzlDLHFDQUEwQztBQUMxQyx5Q0FBOEM7QUFDOUMseUNBQThDO0FBQzlDLDZDQUFrRCJ9
|
90
index.js
90
index.js
@@ -1,90 +0,0 @@
|
||||
/// <reference path="./index.ts" />
|
||||
var SmartgitPlugins;
|
||||
(function (SmartgitPlugins) {
|
||||
SmartgitPlugins.init = function () {
|
||||
var plugins = {
|
||||
path: require("path"),
|
||||
beautylog: require("beautylog"),
|
||||
nodegit: require("nodegit"),
|
||||
Q: require("q")
|
||||
};
|
||||
return plugins;
|
||||
};
|
||||
})(SmartgitPlugins || (SmartgitPlugins = {}));
|
||||
/// <reference path="./index.ts" />
|
||||
var SmartgitClone;
|
||||
(function (SmartgitClone) {
|
||||
function init() {
|
||||
var clone = function (options) {
|
||||
/***** URL Checks ******/
|
||||
if (options.from == "undefined" || options.to == "undefined") {
|
||||
plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
|
||||
return;
|
||||
}
|
||||
/***** Path Checks ******/
|
||||
if (!/^\/.*/.test(options.to)) {
|
||||
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
|
||||
return;
|
||||
}
|
||||
plugins.beautylog.log("Now cloning " + options.from);
|
||||
var cloneOptions = {};
|
||||
var cloneRepository = plugins.nodegit.Clone(options.from, options.to, cloneOptions);
|
||||
smartgit.check(cloneRepository);
|
||||
};
|
||||
return clone;
|
||||
}
|
||||
SmartgitClone.init = init;
|
||||
})(SmartgitClone || (SmartgitClone = {}));
|
||||
/// <reference path="./index.ts" />
|
||||
var SmartgitInit;
|
||||
(function (SmartgitInit) {
|
||||
SmartgitInit.init = function () {
|
||||
var gitinit = function (dest) {
|
||||
if (dest === void 0) { dest = "undefined"; }
|
||||
if (dest == "undefined") {
|
||||
return; // ...and return function here if not
|
||||
}
|
||||
var isBare = 0; //lets create a subfolder
|
||||
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
|
||||
// do something with repo here.
|
||||
});
|
||||
};
|
||||
return gitinit;
|
||||
};
|
||||
})(SmartgitInit || (SmartgitInit = {}));
|
||||
/// <reference path="./index.ts" />
|
||||
var SmartgitCommit;
|
||||
(function (SmartgitCommit) {
|
||||
SmartgitCommit.init = function () {
|
||||
var commit = function (pathArg, commitMessage) {
|
||||
var result = plugins.nodegit.index.addByPath(pathArg);
|
||||
if (result == 0) {
|
||||
}
|
||||
};
|
||||
return commit;
|
||||
};
|
||||
})(SmartgitCommit || (SmartgitCommit = {}));
|
||||
/// <reference path="./index.ts" />
|
||||
var SmartgitCheck;
|
||||
(function (SmartgitCheck) {
|
||||
SmartgitCheck.init = function () {
|
||||
var check = function () {
|
||||
return true;
|
||||
};
|
||||
return check;
|
||||
};
|
||||
})(SmartgitCheck || (SmartgitCheck = {}));
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
/// <reference path="smartgit.plugins.ts" />
|
||||
/// <reference path="smartgit.clone.ts" />
|
||||
/// <reference path="smartgit.init.ts" />
|
||||
/// <reference path="smartgit.commit.ts" />
|
||||
/// <reference path="smartgit.check.ts" />
|
||||
var plugins = SmartgitPlugins.init();
|
||||
//Build the smartgit object
|
||||
var smartgit = {};
|
||||
smartgit.clone = SmartgitClone.init();
|
||||
smartgit.commit = SmartgitCommit.init();
|
||||
smartgit.check = SmartgitCheck.init();
|
||||
smartgit.init = SmartgitInit.init();
|
||||
module.exports = smartgit;
|
@@ -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
|
31
npmextra.json
Normal file
31
npmextra.json
Normal 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"
|
||||
}
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"codecov":true,
|
||||
"coverageTreshold":71
|
||||
}
|
79
package.json
79
package.json
@@ -1,45 +1,68 @@
|
||||
{
|
||||
"name": "smartgit",
|
||||
"version": "1.0.2",
|
||||
"description": "smart git wrapper for node",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"name": "@push.rocks/smartgit",
|
||||
"version": "3.2.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": {
|
||||
"cleanTest": "rm -rf test/temp*",
|
||||
"test": "(npm run cleanTest && npmts)",
|
||||
"install": "node dist/postinstall.js"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitlab.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://gitlab.com/pushrocks/smartgit/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartgit",
|
||||
"dependencies": {
|
||||
"@types/minimatch": "*",
|
||||
"@types/shelljs": "^0.3.32",
|
||||
"beautylog": "^6.0.0",
|
||||
"q": "^1.4.1",
|
||||
"shelljs": "^0.7.5",
|
||||
"simple-git": "^1.62.0",
|
||||
"smartfile": "^4.1.0",
|
||||
"smartpath": "^3.2.5",
|
||||
"smartstring": "^2.0.22",
|
||||
"typings-global": "^1.0.14"
|
||||
"@push.rocks/smartenv": "^5.0.13",
|
||||
"@push.rocks/smartfile": "^11.2.5",
|
||||
"@push.rocks/smartpath": "^6.0.0",
|
||||
"@push.rocks/smartpromise": "^4.2.3",
|
||||
"@push.rocks/smartshell": "^3.2.3",
|
||||
"@push.rocks/smartstring": "^4.0.15",
|
||||
"@push.rocks/smarttime": "^4.1.1",
|
||||
"@types/diff": "^8.0.0",
|
||||
"diff": "^8.0.2",
|
||||
"isomorphic-git": "^1.32.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.30",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
"@git.zone/tsbuild": "^2.6.4",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^2.3.2"
|
||||
},
|
||||
"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"
|
||||
],
|
||||
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
||||
}
|
||||
|
9472
pnpm-lock.yaml
generated
Normal file
9472
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
4
pnpm-workspace.yaml
Normal file
4
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
onlyBuiltDependencies:
|
||||
- esbuild
|
||||
- mongodb-memory-server
|
||||
- puppeteer
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@@ -0,0 +1 @@
|
||||
|
238
readme.md
Normal file
238
readme.md
Normal file
@@ -0,0 +1,238 @@
|
||||
# @push.rocks/smartgit
|
||||
|
||||
> 🚀 **Modern Git operations for Node.js** - A powerful TypeScript wrapper around isomorphic-git that makes repository management and analysis a breeze
|
||||
|
||||
[](https://badge.fury.io/js/@push.rocks%2Fsmartgit)
|
||||
[](https://www.typescriptlang.org/)
|
||||
|
||||
## ✨ What is SmartGit?
|
||||
|
||||
SmartGit is a sophisticated, promise-based Git toolkit designed for Node.js applications. Built on top of `isomorphic-git`, it provides a clean, intuitive API for repository management, diff analysis, and commit history exploration. Perfect for automation tools, CI/CD pipelines, and any application that needs to interact with Git repositories programmatically.
|
||||
|
||||
## 🎯 Key Features
|
||||
|
||||
- **🔧 Repository Management** - Create, clone, and open repositories with ease
|
||||
- **🌐 Remote Operations** - Manage remotes and push changes effortlessly
|
||||
- **📊 Diff Analysis** - Get detailed diffs of uncommitted changes
|
||||
- **📚 Commit History** - Extract commit messages with metadata and version tracking
|
||||
- **⚡ Async/Await** - Modern promise-based API throughout
|
||||
- **🛡️ TypeScript First** - Full type safety and IntelliSense support
|
||||
- **🎯 Production Ready** - Battle-tested and actively maintained
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
```bash
|
||||
# Using pnpm (recommended)
|
||||
pnpm install @push.rocks/smartgit
|
||||
|
||||
# Using npm
|
||||
npm install @push.rocks/smartgit
|
||||
|
||||
# Using yarn
|
||||
yarn add @push.rocks/smartgit
|
||||
```
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
```typescript
|
||||
import { Smartgit } from '@push.rocks/smartgit';
|
||||
|
||||
// Initialize SmartGit
|
||||
const smartgit = new Smartgit();
|
||||
await smartgit.init();
|
||||
|
||||
// Clone a repository
|
||||
const repo = await smartgit.createRepoByClone(
|
||||
'https://github.com/username/repo.git',
|
||||
'./local-repo'
|
||||
);
|
||||
|
||||
console.log('🎉 Repository cloned successfully!');
|
||||
```
|
||||
|
||||
## 📖 Usage Guide
|
||||
|
||||
### 🏗️ Repository Operations
|
||||
|
||||
#### Creating a New Repository
|
||||
|
||||
```typescript
|
||||
const repo = await smartgit.createRepoByInit('./my-new-repo');
|
||||
```
|
||||
|
||||
#### Cloning from Remote
|
||||
|
||||
```typescript
|
||||
const repo = await smartgit.createRepoByClone(
|
||||
'https://github.com/octocat/Hello-World.git',
|
||||
'./hello-world'
|
||||
);
|
||||
```
|
||||
|
||||
#### Opening Existing Repository
|
||||
|
||||
```typescript
|
||||
const repo = await smartgit.createRepoByOpen('./existing-repo');
|
||||
```
|
||||
|
||||
### 🌐 Working with Remotes
|
||||
|
||||
#### List All Remotes
|
||||
|
||||
```typescript
|
||||
const remotes = await repo.listRemotes();
|
||||
console.log(remotes);
|
||||
// Output: [{ remote: 'origin', url: 'https://github.com/...' }]
|
||||
```
|
||||
|
||||
#### Ensure Remote Exists
|
||||
|
||||
```typescript
|
||||
await repo.ensureRemote('origin', 'https://github.com/username/repo.git');
|
||||
```
|
||||
|
||||
#### Get Remote URL
|
||||
|
||||
```typescript
|
||||
const originUrl = await repo.getUrlForRemote('origin');
|
||||
console.log(`📡 Origin URL: ${originUrl}`);
|
||||
```
|
||||
|
||||
#### Push to Remote
|
||||
|
||||
```typescript
|
||||
await repo.pushBranchToRemote('main', 'origin');
|
||||
console.log('✅ Changes pushed successfully!');
|
||||
```
|
||||
|
||||
### 📊 Diff Analysis
|
||||
|
||||
Get a detailed diff of uncommitted changes (perfect for code review automation):
|
||||
|
||||
```typescript
|
||||
const diffs = await repo.getUncommittedDiff(['node_modules/*', '*.log']);
|
||||
|
||||
diffs.forEach(diff => {
|
||||
console.log('📝 File changes:');
|
||||
console.log(diff);
|
||||
});
|
||||
```
|
||||
|
||||
### 📚 Commit History Analysis
|
||||
|
||||
Extract commit history with package.json version tracking:
|
||||
|
||||
```typescript
|
||||
const history = await repo.getAllCommitMessages();
|
||||
|
||||
history.forEach(commit => {
|
||||
console.log(`🕐 ${commit.date} | v${commit.version} | ${commit.message}`);
|
||||
});
|
||||
|
||||
// Example output:
|
||||
// 🕐 2024-01-15 | v1.2.3 | feat: add new authentication method
|
||||
// 🕐 2024-01-14 | v1.2.2 | fix: resolve memory leak in parser
|
||||
```
|
||||
|
||||
## 🛠️ Advanced Usage
|
||||
|
||||
### Error Handling
|
||||
|
||||
```typescript
|
||||
try {
|
||||
const repo = await smartgit.createRepoByClone(invalidUrl, './test');
|
||||
} catch (error) {
|
||||
console.error('❌ Clone failed:', error.message);
|
||||
}
|
||||
```
|
||||
|
||||
### Working with Multiple Repositories
|
||||
|
||||
```typescript
|
||||
const smartgit = new Smartgit();
|
||||
await smartgit.init();
|
||||
|
||||
const repositories = [
|
||||
await smartgit.createRepoByOpen('./repo1'),
|
||||
await smartgit.createRepoByOpen('./repo2'),
|
||||
await smartgit.createRepoByOpen('./repo3')
|
||||
];
|
||||
|
||||
// Analyze all repositories
|
||||
for (const repo of repositories) {
|
||||
const remotes = await repo.listRemotes();
|
||||
console.log(`📂 Repository has ${remotes.length} remotes`);
|
||||
}
|
||||
```
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
SmartGit is built with a clean, modular architecture:
|
||||
|
||||
- **`Smartgit`** - Main entry point and repository factory
|
||||
- **`GitRepo`** - Individual repository operations and analysis
|
||||
- **`isomorphic-git`** - Underlying Git implementation
|
||||
- **Environment Detection** - Automatic Node.js environment setup
|
||||
|
||||
## 🎯 Use Cases
|
||||
|
||||
- **🤖 Automation Scripts** - Automate repository management and analysis
|
||||
- **🔄 CI/CD Pipelines** - Repository operations in build processes
|
||||
- **📊 Code Analysis Tools** - Extract commit data and diff analysis
|
||||
- **🛠️ Developer Tools** - Build Git-powered development utilities
|
||||
- **📱 Release Management** - Track versions and generate changelogs
|
||||
|
||||
## 🔧 Requirements
|
||||
|
||||
- **Node.js** 16+ (Browser support not available)
|
||||
- **Git repository** access (for clone operations)
|
||||
- **TypeScript** 4+ (recommended)
|
||||
|
||||
## 🤝 API Reference
|
||||
|
||||
### Smartgit Class
|
||||
|
||||
| Method | Description | Returns |
|
||||
|--------|-------------|---------|
|
||||
| `init()` | Initialize the SmartGit instance | `Promise<void>` |
|
||||
| `createRepoByInit(dir)` | Create new repository | `Promise<GitRepo>` |
|
||||
| `createRepoByClone(url, dir)` | Clone repository | `Promise<GitRepo>` |
|
||||
| `createRepoByOpen(dir)` | Open existing repository | `Promise<GitRepo>` |
|
||||
|
||||
### GitRepo Class
|
||||
|
||||
| Method | Description | Returns |
|
||||
|--------|-------------|---------|
|
||||
| `listRemotes()` | List all remotes | `Promise<{remote: string, url: string}[]>` |
|
||||
| `ensureRemote(name, url)` | Ensure remote exists | `Promise<void>` |
|
||||
| `getUrlForRemote(name)` | Get URL for remote | `Promise<string>` |
|
||||
| `pushBranchToRemote(branch, remote)` | Push branch to remote | `Promise<void>` |
|
||||
| `getUncommittedDiff(excludeFiles?)` | Get uncommitted changes | `Promise<string[]>` |
|
||||
| `getAllCommitMessages()` | Get commit history | `Promise<CommitInfo[]>` |
|
||||
|
||||
## 💡 Pro Tips
|
||||
|
||||
- **🔧 Always call `init()`** before using any repository operations
|
||||
- **📁 Use absolute paths** for repository directories when possible
|
||||
- **🚫 Exclude large files** from diff analysis using the `excludeFiles` parameter
|
||||
- **⚡ Batch operations** when working with multiple repositories
|
||||
- **🛡️ Handle errors gracefully** - network issues can cause clone operations to fail
|
||||
|
||||
## 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
9
test.js
@@ -1,9 +0,0 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var smartgit = require("./index.js");
|
||||
var beautylog = require("beautylog");
|
||||
var path = require("path");
|
||||
smartgit.clone({
|
||||
from: "https://github.com/pushrocks/docs.git",
|
||||
to: path.resolve("./test/temp/")
|
||||
});
|
||||
beautylog.success("Test successfull");
|
Submodule test/temp3 deleted from a261a2ea02
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@@ -1 +0,0 @@
|
||||
import 'typings-test';
|
110
test/test.js
110
test/test.js
@@ -1,110 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
let shelljs = require('shelljs');
|
||||
const path = require("path");
|
||||
const should = require("should");
|
||||
const smartgit = require("../dist/index");
|
||||
let paths = {
|
||||
temp1: path.resolve('./test/temp/'),
|
||||
temp2: path.resolve('./test/temp2/'),
|
||||
temp3: path.resolve('./test/temp3'),
|
||||
temp4: path.resolve('./test/temp4'),
|
||||
noGit: path.resolve('./test/')
|
||||
};
|
||||
describe('smartgit', function () {
|
||||
let testGitRepo;
|
||||
let testGitRepoCloned;
|
||||
let testGitRepoInit;
|
||||
describe('instance', function () {
|
||||
it('should error for invalid path', function (done) {
|
||||
try {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1);
|
||||
}
|
||||
catch (err) {
|
||||
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}
|
||||
});
|
||||
it('should init a new repo', function (done) {
|
||||
this.timeout(40000);
|
||||
smartgit.createRepoFromInit(paths.temp1)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
it('should create am instance for an existing repo', function () {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1);
|
||||
should(testGitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
});
|
||||
it('should clone a repository using ssh and sshkey', function (done) {
|
||||
this.timeout(40000);
|
||||
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp2)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
it('should clone a repository using https', function (done) {
|
||||
this.timeout(40000);
|
||||
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp3)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo);
|
||||
done();
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('.add', function () {
|
||||
it('should add a file to an existing repository', function () {
|
||||
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`);
|
||||
testGitRepo.addAll(paths.temp1);
|
||||
});
|
||||
});
|
||||
describe('.check()', function (done) {
|
||||
it('should check a git repo', function () {
|
||||
let checkResult = testGitRepo.check();
|
||||
should(checkResult).be.true();
|
||||
});
|
||||
});
|
||||
describe('commit', function () {
|
||||
it('should commit a new file to an existing repository', function () {
|
||||
testGitRepo.commit('added a new file');
|
||||
});
|
||||
});
|
||||
describe('pull', function () {
|
||||
this.timeout(40000);
|
||||
it('should pull from origin', function (done) {
|
||||
testGitRepo.pull()
|
||||
.then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('push', function () {
|
||||
this.timeout(40000);
|
||||
it('should push to origin', function (done) {
|
||||
testGitRepo.push('origin', 'master')
|
||||
.then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('remote', function () {
|
||||
it('should add a remote', function () {
|
||||
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo');
|
||||
});
|
||||
it('should', function (done) {
|
||||
testGitRepo.remoteList()
|
||||
.then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzd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C,CAAC;IACP,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,QAAQ,EAAC;IAElB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,QAAQ,EAAC;IAElB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,EAAC;IAEhB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
155
test/test.ts
155
test/test.ts
@@ -1,112 +1,51 @@
|
||||
import 'typings-test'
|
||||
import beautylog = require('beautylog')
|
||||
let shelljs = require('shelljs')
|
||||
import path = require('path')
|
||||
import * as should from 'should'
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartgit from '../ts/index.js';
|
||||
|
||||
import smartgit = require('../dist/index')
|
||||
let paths = {
|
||||
temp1: path.resolve('./test/temp/'),
|
||||
temp2: path.resolve('./test/temp2/'),
|
||||
temp3: path.resolve('./test/temp3'),
|
||||
temp4: path.resolve('./test/temp4'),
|
||||
noGit: path.resolve('./test/')
|
||||
}
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
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);
|
||||
});
|
||||
|
||||
describe('smartgit', function () {
|
||||
let testGitRepo: smartgit.GitRepo
|
||||
let testGitRepoCloned: smartgit.GitRepo
|
||||
let testGitRepoInit: smartgit.GitRepo
|
||||
describe('instance', function () {
|
||||
it('should error for invalid path', function (done) {
|
||||
try {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1)
|
||||
} catch (err) {
|
||||
should(testGitRepo).not.be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}
|
||||
})
|
||||
it('should init a new repo', function (done) {
|
||||
this.timeout(40000)
|
||||
smartgit.createRepoFromInit(paths.temp1)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}).catch(err => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
it('should create am instance for an existing repo', function () {
|
||||
testGitRepo = new smartgit.GitRepo(paths.temp1)
|
||||
should(testGitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
})
|
||||
it('should clone a repository using ssh and sshkey', function (done) {
|
||||
this.timeout(40000)
|
||||
smartgit.createRepoFromClone('git@gitlab.com:sandboxzone/sandbox-testrepo.git', paths.temp2)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}).catch(err => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
it('should clone a repository using https', function (done) {
|
||||
this.timeout(40000)
|
||||
smartgit.createRepoFromClone('https://gitlab.com/sandboxzone/sandbox-testrepo.git', paths.temp3)
|
||||
.then((gitRepo) => {
|
||||
should(gitRepo).be.instanceOf(smartgit.GitRepo)
|
||||
done()
|
||||
}).catch(err => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('.add', function () {
|
||||
it('should add a file to an existing repository', function () {
|
||||
shelljs.exec(`(cd ${paths.temp1} && cp ../test.js .)`)
|
||||
testGitRepo.addAll(paths.temp1)
|
||||
})
|
||||
})
|
||||
describe('.check()', function(done) {
|
||||
it('should check a git repo', function() {
|
||||
let checkResult = testGitRepo.check()
|
||||
should(checkResult).be.true()
|
||||
})
|
||||
})
|
||||
describe('commit', function () {
|
||||
it('should commit a new file to an existing repository', function () {
|
||||
testGitRepo.commit('added a new file')
|
||||
})
|
||||
})
|
||||
describe('pull', function () {
|
||||
this.timeout(40000)
|
||||
it('should pull from origin', function (done) {
|
||||
testGitRepo.pull()
|
||||
.then(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('push', function () {
|
||||
this.timeout(40000)
|
||||
it('should push to origin', function (done) {
|
||||
testGitRepo.push('origin', 'master')
|
||||
.then(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('remote', function () {
|
||||
it('should add a remote', function () {
|
||||
testGitRepo.remoteAdd('origin2', 'https://github.com/pushrocks/somerepo')
|
||||
})
|
||||
it('should', function(done) {
|
||||
testGitRepo.remoteList()
|
||||
.then(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
tap.test('should create a new repo at .nogit', async () => {
|
||||
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir);
|
||||
});
|
||||
|
||||
tap.test('should clone a repo', async () => {
|
||||
const gitRepo = await testSmartgitInstance.createRepoByClone(
|
||||
'https://gitlab.com/push.rocks/smartfile.git',
|
||||
testRepoDirSmartfile
|
||||
);
|
||||
});
|
||||
|
||||
tap.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
8
ts/00_commitinfo_data.ts
Normal 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.'
|
||||
}
|
33
ts/index.ts
33
ts/index.ts
@@ -1,31 +1,2 @@
|
||||
import * as q from 'q'
|
||||
import plugins = require("./smartgit.plugins");
|
||||
|
||||
import { GitRepo } from './smartgit.classes.gitrepo'
|
||||
export {
|
||||
GitRepo
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(toArg)
|
||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`)
|
||||
let newRepo = new GitRepo(toArg)
|
||||
done.resolve(newRepo)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
||||
plugins.shelljs.exec(`cd ${destinationDirArg} && git init`)
|
||||
let newRepo = new GitRepo(destinationDirArg)
|
||||
done.resolve(newRepo)
|
||||
return done.promise
|
||||
}
|
||||
export * from './smartgit.classes.gitrepo.js';
|
||||
export * from './smartgit.classes.smartgit.js';
|
||||
|
@@ -1,150 +1,228 @@
|
||||
import * as q from 'q'
|
||||
import * as plugins from './smartgit.plugins'
|
||||
import * as plugins from './smartgit.plugins.js';
|
||||
import { Smartgit } from './smartgit.classes.smartgit.js';
|
||||
|
||||
/**
|
||||
* class GitRepo allows access to git directories from node
|
||||
*/
|
||||
export class GitRepo {
|
||||
repoBase: string
|
||||
constructor(repoBaseArg: string) {
|
||||
this.repoBase = repoBaseArg
|
||||
if (!this.check()) {
|
||||
throw new Error('no valid git repo')
|
||||
}
|
||||
// STATIC
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
public static async fromCloningIntoDir(
|
||||
smartgitRefArg: Smartgit,
|
||||
fromArg: string,
|
||||
toArg: string
|
||||
): Promise<GitRepo> {
|
||||
const dirArg = plugins.path.resolve(toArg);
|
||||
await plugins.isomorphicGit.clone({
|
||||
dir: toArg,
|
||||
fs: smartgitRefArg.envDeps.fs,
|
||||
http: smartgitRefArg.envDeps.http,
|
||||
url: fromArg,
|
||||
});
|
||||
return new GitRepo(smartgitRefArg, toArg);
|
||||
}
|
||||
|
||||
public static async fromCreatingRepoInDir(
|
||||
smartgitRefArg: Smartgit,
|
||||
dirArg: string
|
||||
): Promise<GitRepo> {
|
||||
dirArg = plugins.path.resolve(dirArg);
|
||||
await plugins.isomorphicGit.init({
|
||||
dir: dirArg,
|
||||
fs: smartgitRefArg.envDeps.fs,
|
||||
});
|
||||
return new GitRepo(smartgitRefArg, dirArg);
|
||||
}
|
||||
|
||||
public static async fromOpeningRepoDir(smartgitRefArg: Smartgit, dirArg: string) {
|
||||
dirArg = plugins.path.resolve(dirArg);
|
||||
return new GitRepo(smartgitRefArg, dirArg);
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public smartgitRef: Smartgit;
|
||||
public repoDir: string;
|
||||
|
||||
constructor(smartgitRefArg: Smartgit, repoDirArg: string) {
|
||||
this.smartgitRef = smartgitRefArg;
|
||||
this.repoDir = repoDirArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* lists remotes
|
||||
*/
|
||||
public async listRemotes(): Promise<
|
||||
{
|
||||
remote: string;
|
||||
url: string;
|
||||
}[]
|
||||
> {
|
||||
const remotes = await plugins.isomorphicGit.listRemotes({
|
||||
fs: this.smartgitRef.envDeps.fs,
|
||||
dir: this.repoDir,
|
||||
});
|
||||
return remotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* ensures the 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the Repo is valid
|
||||
*/
|
||||
check(): boolean {
|
||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(this.repoBase, '.git'))
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* stage all files in working directory
|
||||
*/
|
||||
addAll(dirPathArg: string) {
|
||||
let done = q.defer()
|
||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`)
|
||||
done.resolve(dirPathArg)
|
||||
return done.promise
|
||||
};
|
||||
|
||||
/**
|
||||
* add a remote to the GitRepo
|
||||
*/
|
||||
remoteAdd(remoteNameArg: string, remoteLinkArg: string) {
|
||||
let done = q.defer()
|
||||
if (!remoteNameArg) {
|
||||
let err = new Error('smartgit.remote.add expects a valid remote name')
|
||||
plugins.beautylog.error(err.message)
|
||||
done.reject(err)
|
||||
return done.promise
|
||||
};
|
||||
if (!remoteLinkArg) {
|
||||
let err = new Error()
|
||||
plugins.beautylog.error(err.message)
|
||||
done.reject(err)
|
||||
return done.promise
|
||||
};
|
||||
|
||||
// if everything is all right proceed
|
||||
plugins.shelljs.exec(`cd ${this.repoBase} && git remote add ${remoteNameArg} ${remoteLinkArg}`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* list remotes for a Gip
|
||||
*/
|
||||
remoteList() {
|
||||
let done = q.defer()
|
||||
let remotes = {}
|
||||
plugins.shelljs.exec(`cd ${this.repoBase} && git remote -v`)
|
||||
done.resolve(remotes)
|
||||
return done.promise
|
||||
};
|
||||
|
||||
/**
|
||||
* remove remote
|
||||
*/
|
||||
remoteRemove(dirPathArg: string) {
|
||||
let done = q.defer()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* commit all files that are currently staged
|
||||
*/
|
||||
commit(commitMessage: string) {
|
||||
let done = q.defer()
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git commit -m "${commitMessage}")`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pull latest changes from remote
|
||||
*/
|
||||
pull(sourceArg: string = '', branchArg: string = '') {
|
||||
let done = q.defer()
|
||||
// if everything is allright proceed
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git pull ${sourceArg} ${branchArg})`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* push new commits to remote
|
||||
*/
|
||||
push(remoteNameArg: string = '', remoteBranchArg: string = '') {
|
||||
let done = q.defer()
|
||||
// if everything seems allright proceed
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git push ${remoteNameArg} ${remoteBranchArg})`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* sync
|
||||
*/
|
||||
sync() {
|
||||
this.pull().then(() => {
|
||||
this.push()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* get the current status
|
||||
*/
|
||||
status() {
|
||||
let done = q.defer()
|
||||
plugins.shelljs.exec(`(cd ${this.repoBase} && git status)`)
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo Instance after cloning a project
|
||||
*/
|
||||
export let createRepoFromClone = (fromArg: string, toArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(toArg)
|
||||
plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`)
|
||||
let newRepo = new GitRepo(toArg)
|
||||
done.resolve(newRepo)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo instance after initializing a new Git Repository
|
||||
*/
|
||||
export let createRepoFromInit = (destinationDirArg: string) => {
|
||||
let done = q.defer<GitRepo>()
|
||||
plugins.smartfile.fs.ensureDir(destinationDirArg)
|
||||
plugins.shelljs.exec(`cd destinationDirArg && git init`)
|
||||
let newRepo = new GitRepo(destinationDirArg)
|
||||
done.resolve(newRepo)
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
90
ts/smartgit.classes.smartgit.ts
Normal file
90
ts/smartgit.classes.smartgit.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import * as plugins from './smartgit.plugins.js';
|
||||
import { GitRepo } from './smartgit.classes.gitrepo.js';
|
||||
|
||||
interface IEnvDeps {
|
||||
fs: typeof import('fs') | null;
|
||||
http: any | null; // isomorphic-git http interface
|
||||
}
|
||||
|
||||
/**
|
||||
* class Smartgit provides a high-level interface for git operations
|
||||
* Must be initialized before use by calling init()
|
||||
*/
|
||||
export class Smartgit {
|
||||
public smartenvInstance = new plugins.smartenv.Smartenv();
|
||||
public envDeps: IEnvDeps = {
|
||||
fs: null,
|
||||
http: null,
|
||||
};
|
||||
|
||||
/**
|
||||
* initializes the Smartgit instance with required environment dependencies
|
||||
* Must be called before using any repository methods
|
||||
*/
|
||||
public async init(): Promise<void> {
|
||||
try {
|
||||
if (this.smartenvInstance.isNode) {
|
||||
this.envDeps.fs = await this.smartenvInstance.getSafeNodeModule('fs');
|
||||
this.envDeps.http = await this.smartenvInstance.getSafeNodeModule(
|
||||
'isomorphic-git/http/node'
|
||||
);
|
||||
} else {
|
||||
throw new Error('currently only node.js is supported.');
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to initialize Smartgit: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
private ensureInitialized(): void {
|
||||
if (!this.envDeps.fs || !this.envDeps.http) {
|
||||
throw new Error('Smartgit must be initialized before use. Call init() first.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo instance by cloning from a remote URL
|
||||
* @param fromUrlArg the URL to clone from
|
||||
* @param toDirArg the directory to clone into
|
||||
* @returns Promise<GitRepo> the created repository instance
|
||||
*/
|
||||
public async createRepoByClone(fromUrlArg: string, toDirArg: string): Promise<GitRepo> {
|
||||
this.ensureInitialized();
|
||||
try {
|
||||
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg);
|
||||
return repo;
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to clone repository: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo instance by initializing a new repository in a directory
|
||||
* @param dirArg the directory to initialize the repository in
|
||||
* @returns Promise<GitRepo> the created repository instance
|
||||
*/
|
||||
public async createRepoByInit(dirArg: string): Promise<GitRepo> {
|
||||
this.ensureInitialized();
|
||||
try {
|
||||
const repo = await GitRepo.fromCreatingRepoInDir(this, dirArg);
|
||||
return repo;
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to initialize repository: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new GitRepo instance by opening an existing repository in a directory
|
||||
* @param dirArg the directory containing the existing repository
|
||||
* @returns Promise<GitRepo> the opened repository instance
|
||||
*/
|
||||
public async createRepoByOpen(dirArg: string): Promise<GitRepo> {
|
||||
this.ensureInitialized();
|
||||
try {
|
||||
const repo = await GitRepo.fromOpeningRepoDir(this, dirArg);
|
||||
return repo;
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to open repository: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,19 @@
|
||||
import 'typings-global'
|
||||
export import path = require('path')
|
||||
export import beautylog = require('beautylog')
|
||||
export import shelljs = require('shelljs')
|
||||
export import smartfile = require('smartfile')
|
||||
export import smartpath = require('smartpath')
|
||||
export import smartstring = require('smartstring')
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
import * as smartenv from '@push.rocks/smartenv';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
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 };
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user