Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
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
|
137
.gitlab-ci.yml
137
.gitlab-ci.yml
@ -1,137 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: '$CI_BUILD_STAGE'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g tslint typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
63
changelog.md
Normal file
63
changelog.md
Normal 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
|
@ -6,12 +6,26 @@
|
|||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartgit",
|
"gitrepo": "smartgit",
|
||||||
"shortDescription": "smart wrapper for nodegit",
|
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.",
|
||||||
"npmPackagename": "@pushrocks/smartgit",
|
"npmPackagename": "@push.rocks/smartgit",
|
||||||
"license": "MIT"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
14286
package-lock.json
generated
14286
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@ -1,43 +1,54 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartgit",
|
"name": "@push.rocks/smartgit",
|
||||||
"version": "2.0.3",
|
"version": "3.1.1",
|
||||||
"description": "smart wrapper for nodegit",
|
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitlab.com/pushrocks/smartgit.git"
|
"url": "https://code.foss.global/push.rocks/smartgit.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"json",
|
"git",
|
||||||
"jade",
|
"nodegit",
|
||||||
"template"
|
"version control",
|
||||||
|
"git wrapper",
|
||||||
|
"programming",
|
||||||
|
"development",
|
||||||
|
"code management",
|
||||||
|
"repository management",
|
||||||
|
"git operations"
|
||||||
],
|
],
|
||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartgit/issues"
|
"url": "https://gitlab.com/pushrocks/smartgit/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
"homepage": "https://code.foss.global/push.rocks/smartgit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartenv": "^5.0.2",
|
"@push.rocks/smartenv": "^5.0.12",
|
||||||
"@pushrocks/smartfile": "^10.0.4",
|
"@push.rocks/smartfile": "^11.0.20",
|
||||||
"@pushrocks/smartpath": "^5.0.5",
|
"@push.rocks/smartpath": "^5.0.18",
|
||||||
"@pushrocks/smartpromise": "^3.1.7",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"@pushrocks/smartshell": "^2.0.30",
|
"@push.rocks/smartshell": "^3.0.5",
|
||||||
"@pushrocks/smartstring": "^4.0.2",
|
"@push.rocks/smartstring": "^4.0.15",
|
||||||
"@types/minimatch": "^3.0.5",
|
"@push.rocks/smarttime": "^4.0.6",
|
||||||
"isomorphic-git": "^1.19.1"
|
"@types/diff": "^5.2.1",
|
||||||
|
"@types/minimatch": "^5.1.2",
|
||||||
|
"diff": "^5.2.0",
|
||||||
|
"isomorphic-git": "^1.25.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.63",
|
"@git.zone/tsbuild": "^2.1.80",
|
||||||
"@gitzone/tstest": "^1.0.72",
|
"@git.zone/tsrun": "^1.2.44",
|
||||||
"@pushrocks/tapbundle": "^5.0.4"
|
"@git.zone/tstest": "^1.0.90",
|
||||||
|
"@push.rocks/tapbundle": "^5.0.23"
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
|
6971
pnpm-lock.yaml
generated
Normal file
6971
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
185
readme.md
185
readme.md
@ -1,88 +1,137 @@
|
|||||||
# @pushrocks/smartgit
|
# @push.rocks/smartgit
|
||||||
smart wrapper for nodegit
|
smart wrapper for nodegit
|
||||||
|
|
||||||
## Availabililty and Links
|
## Install
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartgit)
|
To install @push.rocks/smartgit, use the following command with npm:
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartgit)
|
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartgit)
|
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartgit/)
|
|
||||||
|
|
||||||
## Status for master
|
```bash
|
||||||
|
npm install @push.rocks/smartgit --save
|
||||||
|
```
|
||||||
|
|
||||||
Status Category | Status Badge
|
Or if you prefer using yarn:
|
||||||
-- | --
|
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
```bash
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
yarn add @push.rocks/smartgit
|
||||||
npm | [](https://lossless.cloud)
|
```
|
||||||
Snyk | [](https://lossless.cloud)
|
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
Make sure you have `node` installed on your system to use this package.
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
Code Style | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
We recommend the use of TypeScript for best in class intellisense
|
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.
|
||||||
|
|
||||||
```javascript
|
### Setting Up
|
||||||
// import smartgit:
|
|
||||||
import { GitRepo } from 'smartgit';
|
|
||||||
|
|
||||||
// Initialize smartgit:
|
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.
|
||||||
// -- 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:
|
```typescript
|
||||||
let myExistingGitRepo = new GitRepo('/path/to/existing/git/repo/');
|
import { Smartgit } from '@push.rocks/smartgit';
|
||||||
|
|
||||||
// -- 2. cloned Git Repo:
|
// Initialize the Smartgit instance
|
||||||
let myClonedGitRepo: GitRepo;
|
const smartgit = new Smartgit();
|
||||||
smartgit.createRepoFromClone('git@github.com:username/reponame.git').then((gitRepo) => {
|
await smartgit.init();
|
||||||
// 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
|
### Creating, Cloning, and Opening Repositories
|
||||||
|
|
||||||
[](https://push.rocks)
|
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
|
||||||
|
|
||||||
## Contribution
|
```typescript
|
||||||
|
const pathToNewRepo = '/path/to/your/new/repo';
|
||||||
|
const newRepo = await smartgit.createRepoByInit(pathToNewRepo);
|
||||||
|
```
|
||||||
|
|
||||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
#### Cloning a Repository
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
```typescript
|
||||||
|
const cloneUrl = 'https://github.com/yourusername/your-repo.git';
|
||||||
|
const pathToClone = '/path/to/clone/repo';
|
||||||
|
const clonedRepo = await smartgit.createRepoByClone(cloneUrl, pathToClone);
|
||||||
|
```
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
#### Opening an Existing Repository
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
```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.
|
||||||
|
41
test/test.ts
41
test/test.ts
@ -1,26 +1,51 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import * as smartgit from '../ts/index.js';
|
import * as smartgit from '../ts/index.js';
|
||||||
|
|
||||||
import * as smartpath from '@pushrocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
const __dirname = smartpath.get.dirnameFromImportMetaUrl(import.meta.url);
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
let testSmartgitInstance: smartgit.Smartgit;
|
let testSmartgitInstance: smartgit.Smartgit;
|
||||||
const testRepoDir = path.join(__dirname, '../.nogit/testrepo');
|
const packageDir = path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
const testRepoDirSmartfile = path.join(__dirname, '../.nogit/pushrocks_smartfile')
|
const testRepoDir = path.join(packageDir, './.nogit/testrepo');
|
||||||
|
const testRepoDirSmartfile = path.join(packageDir, './.nogit/pushrocks_smartfile');
|
||||||
|
|
||||||
tap.test('should create a valid smartgit instance', async () => {
|
tap.test('should create a valid smartgit instance', async () => {
|
||||||
testSmartgitInstance = new smartgit.Smartgit();
|
testSmartgitInstance = new smartgit.Smartgit();
|
||||||
await testSmartgitInstance.init();
|
await testSmartgitInstance.init();
|
||||||
expect(testSmartgitInstance).toBeInstanceOf(smartgit.Smartgit);
|
expect(testSmartgitInstance).toBeInstanceOf(smartgit.Smartgit);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should create a new repo at .nogit', async () => {
|
tap.test('should create a new repo at .nogit', async () => {
|
||||||
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir);
|
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should clone a repo', async () => {
|
tap.test('should clone a repo', async () => {
|
||||||
const gitRepo = await testSmartgitInstance.createRepoByClone('https://gitlab.com/pushrocks/smartfile.git', testRepoDirSmartfile);
|
const gitRepo = await testSmartgitInstance.createRepoByClone(
|
||||||
|
'https://gitlab.com/push.rocks/smartfile.git',
|
||||||
|
testRepoDirSmartfile
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
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();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartgit',
|
name: '@push.rocks/smartgit',
|
||||||
version: '2.0.3',
|
version: '3.1.1',
|
||||||
description: 'smart wrapper for nodegit'
|
description: 'A smart wrapper for nodegit that simplifies Git operations in Node.js.'
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as plugins from './smartgit.plugins.js';
|
import * as plugins from './smartgit.plugins.js';
|
||||||
|
|
||||||
import { Smartgit } from './smartgit.classes.smartgit.js';
|
import { Smartgit } from './smartgit.classes.smartgit.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,30 +67,29 @@ export class GitRepo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ensures the existance of a remote within a repository
|
* ensures the existence of a remote within a repository
|
||||||
* @param remoteNameArg
|
* @param remoteNameArg
|
||||||
* @param remoteUrlArg
|
* @param remoteUrlArg
|
||||||
*/
|
*/
|
||||||
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
|
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
|
||||||
const remotes = await this.listRemotes();
|
const remotes = await this.listRemotes();
|
||||||
const existingRemote =
|
const existingRemote = remotes.find((itemArg) => itemArg.remote === remoteNameArg);
|
||||||
remotes.find((itemArg) => itemArg.remote === remoteNameArg);
|
|
||||||
if (existingRemote) {
|
if (existingRemote) {
|
||||||
if (existingRemote.url !== remoteUrlArg) {
|
if (existingRemote.url !== remoteUrlArg) {
|
||||||
await plugins.isomorphicGit.deleteRemote({
|
await plugins.isomorphicGit.deleteRemote({
|
||||||
remote: remoteNameArg,
|
remote: remoteNameArg,
|
||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
dir: this.repoDir
|
dir: this.repoDir,
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
await plugins.isomorphicGit.addRemote({
|
await plugins.isomorphicGit.addRemote({
|
||||||
remote: remoteNameArg,
|
remote: remoteNameArg,
|
||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
url: remoteUrlArg
|
url: remoteUrlArg,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +97,7 @@ export class GitRepo {
|
|||||||
*/
|
*/
|
||||||
public async getUrlForRemote(remoteName: string): Promise<string> {
|
public async getUrlForRemote(remoteName: string): Promise<string> {
|
||||||
const remotes = await this.listRemotes();
|
const remotes = await this.listRemotes();
|
||||||
const existingRemote = remotes.find(remoteArg => remoteArg.remote === remoteName);
|
const existingRemote = remotes.find((remoteArg) => remoteArg.remote === remoteName);
|
||||||
return existingRemote?.url;
|
return existingRemote?.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +106,123 @@ export class GitRepo {
|
|||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
http: this.smartgitRef.envDeps.http,
|
http: this.smartgitRef.envDeps.http,
|
||||||
ref: branchName,
|
ref: branchName,
|
||||||
remote: remoteName
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,28 +8,30 @@ export class Smartgit {
|
|||||||
http: any;
|
http: any;
|
||||||
} = {
|
} = {
|
||||||
fs: null,
|
fs: null,
|
||||||
http: null
|
http: null,
|
||||||
}
|
};
|
||||||
|
|
||||||
constructor() {};
|
constructor() {}
|
||||||
|
|
||||||
public async init() {
|
public async init() {
|
||||||
if (this.smartenvInstance.isNode) {
|
if (this.smartenvInstance.isNode) {
|
||||||
this.envDeps.fs = await this.smartenvInstance.getSafeNodeModule('fs');
|
this.envDeps.fs = await this.smartenvInstance.getSafeNodeModule('fs');
|
||||||
this.envDeps.http = await this.smartenvInstance.getSafeNodeModule('isomorphic-git/http/node/index.js');
|
this.envDeps.http = await this.smartenvInstance.getSafeNodeModule(
|
||||||
|
'isomorphic-git/http/node/index.js'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('currently only node.js is supported.')
|
throw new Error('currently only node.js is supported.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
public async createRepoByClone(fromUrlArg: string, toDirArg: string) {
|
public async createRepoByClone(fromUrlArg: string, toDirArg: string) {
|
||||||
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg)
|
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg);
|
||||||
};
|
}
|
||||||
|
|
||||||
public async createRepoByInit(dirArg: string) {
|
public async createRepoByInit(dirArg: string) {
|
||||||
const repo = await GitRepo.fromCreatingRepoInDir(this, dirArg);
|
const repo = await GitRepo.fromCreatingRepoInDir(this, dirArg);
|
||||||
return repo;
|
return repo;
|
||||||
};
|
}
|
||||||
|
|
||||||
public async createRepoByOpen(dirArg: string) {
|
public async createRepoByOpen(dirArg: string) {
|
||||||
const repo = await GitRepo.fromOpeningRepoDir(this, dirArg);
|
const repo = await GitRepo.fromOpeningRepoDir(this, dirArg);
|
||||||
|
@ -3,15 +3,17 @@ import * as path from 'path';
|
|||||||
|
|
||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
import * as smartenv from '@pushrocks/smartenv';
|
import * as smartenv from '@push.rocks/smartenv';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartpath from '@pushrocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartstring from '@pushrocks/smartstring';
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
|
import * as smarttime from '@push.rocks/smarttime';
|
||||||
|
|
||||||
export { smartenv, smartfile, smartpath, smartpromise, smartstring };
|
export { smartenv, smartfile, smartpath, smartpromise, smartstring, smarttime };
|
||||||
|
|
||||||
// third party
|
// third party
|
||||||
|
import * as diff from 'diff';
|
||||||
import isomorphicGit from 'isomorphic-git';
|
import isomorphicGit from 'isomorphic-git';
|
||||||
|
|
||||||
export { isomorphicGit };
|
export { diff, isomorphicGit };
|
||||||
|
@ -3,8 +3,12 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"useDefineForClassFields": false,
|
"useDefineForClassFields": false,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "NodeNext",
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true,
|
||||||
}
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user