From 7aa83ac730e8602132eb9a34c8c3cdacb10e500a Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 17:38:19 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 17 ++++- package.json | 16 +++-- readme.hints.md | 1 + readme.md | 184 +++++++++++++++++++++++++++++++----------------- 4 files changed, 144 insertions(+), 74 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index 6899eb1..ebca2bb 100644 --- a/npmextra.json +++ b/npmextra.json @@ -9,12 +9,23 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartgit", - "description": "smart wrapper for nodegit", + "description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.", "npmPackagename": "@push.rocks/smartgit", - "license": "MIT" + "license": "MIT", + "keywords": [ + "git", + "nodegit", + "version control", + "git wrapper", + "programming", + "development", + "code management", + "repository management", + "git operations" + ] } }, - "tsdocs": { + "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" } } \ No newline at end of file diff --git a/package.json b/package.json index 0edccf4..1cd892b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@push.rocks/smartgit", "version": "3.0.2", - "description": "smart wrapper for nodegit", + "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", @@ -15,9 +15,15 @@ "url": "https://gitlab.com/pushrocks/smartgit.git" }, "keywords": [ - "json", - "jade", - "template" + "git", + "nodegit", + "version control", + "git wrapper", + "programming", + "development", + "code management", + "repository management", + "git operations" ], "author": "Smart Coordination GmbH (https://push.rocks)", "license": "MIT", @@ -57,4 +63,4 @@ "browserslist": [ "last 1 chrome versions" ] -} +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index a83d49f..db258cd 100644 --- a/readme.md +++ b/readme.md @@ -1,85 +1,137 @@ # @push.rocks/smartgit smart wrapper for nodegit -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartgit) -* [gitlab.com (source)](https://gitlab.com/push.rocks/smartgit) -* [github.com (source mirror)](https://github.com/push.rocks/smartgit) -* [docs (typedoc)](https://push.rocks.gitlab.io/smartgit/) +## Install +To install @push.rocks/smartgit, use the following command with npm: -## Status for master +```bash +npm install @push.rocks/smartgit --save +``` -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartgit/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartgit/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartgit)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartgit)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartgit)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartgit)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartgit)](https://lossless.cloud) +Or if you prefer using yarn: + +```bash +yarn add @push.rocks/smartgit +``` + +Make sure you have `node` installed on your system to use this package. ## Usage -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 -// import smartgit: -import { GitRepo } from 'smartgit'; +### Setting Up -// 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 +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. -// -- 1. existing Git Repo: -let myExistingGitRepo = new GitRepo('/path/to/existing/git/repo/'); +```typescript +import { Smartgit } from '@push.rocks/smartgit'; -// -- 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'); +// Initialize the Smartgit instance +const smartgit = new Smartgit(); +await smartgit.init(); ``` -Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment +### Creating, Cloning, and Opening Repositories -[![npm](https://push.rocks/assets/repo-header.svg)](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. -## Contribution +#### Creating a New Repository -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). :) +```typescript +const pathToNewRepo = '/path/to/your/new/repo'; +const newRepo = await smartgit.createRepoByInit(pathToNewRepo); +``` -For further information read the linked docs at the top of this readme. +#### Cloning a Repository -## Legal -> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +```typescript +const cloneUrl = 'https://github.com/yourusername/your-repo.git'; +const pathToClone = '/path/to/clone/repo'; +const clonedRepo = await smartgit.createRepoByClone(cloneUrl, pathToClone); +``` + +#### Opening an Existing Repository + +```typescript +const pathToExistingRepo = '/path/to/your/existing/repo'; +const existingRepo = await smartgit.createRepoByOpen(pathToExistingRepo); +``` + +### Working with Git Operations + +`Smartgit` simplifies common Git operations, making it easy to execute commands like add, commit, push, and more programmatically. + +#### Adding Changes + +To stage changes, you can add all changes or specify particular files. + +```typescript +// Add all changes to staging +await existingRepo.addAll(); + +// Or specify particular files +await existingRepo.add(['file1.txt', 'path/to/file2.txt']); +``` + +#### Committing Changes + +Once changes are staged, you can commit them. + +```typescript +await existingRepo.commit('Your commit message'); +``` + +#### Pushing to a Remote + +Before pushing, ensure a remote is set up correctly, then push your changes. + +```typescript +await existingRepo.ensureRemote('origin', 'https://github.com/yourusername/your-repo.git'); +await existingRepo.pushBranchToRemote('main', 'origin'); +``` + +### Advanced Features + +`Smartgit` also supports more advanced Git functionalities, such as dealing with branches, managing remotes, and checking repository status. + +#### Listing Remotes + +```typescript +const remotes = await existingRepo.listRemotes(); +console.log(remotes); +``` + +#### Working with Branches + +Branch management such as creating new branches or checking out existing ones can be done through the underlying `isomorphic-git` functions, with `Smartgit` making the setup and usage straightforward. + +### Practical Tips + +- When dealing with asynchronous operations, especially in sequences that depend on the outcome of previous steps (e.g., staging, committing, and pushing), ensure proper error handling, either using `.then().catch()` chains or `try/catch` blocks with async/await. +- For complex Git workflows, consider combining `Smartgit`'s capabilities with other Node.js modules or scripts to automate and streamline your processes. + +### Conclusion + +`@push.rocks/smartgit` provides a versatile and powerful toolkit for Git operations in Node.js applications. By abstracting the complexities of interacting with Git repositories, it enables developers to focus more on developing their logic and less on the intricacies of Git commands. Whether you're managing local repositories, automating deployment workflows, or integrating Git operations into your applications, `Smartgit` offers a comprehensive set of features to address your needs. + +For further examples, contributions, and issues, please refer to the [project's repository](https://gitlab.com/pushrocks/smartgit) and consider contributing to or starring the project if you find it useful. + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.