git-repo-npm v1.0.5
GRPM - Git Repositories as NPM Modules
GRPM is a tool that allows you to use Git repositories as NPM modules in your project. It simplifies the process of managing dependencies from Git repositories and automates the installation and updating of these modules.
Installation
To install GRPM, run the following command:
npm install -g git-repo-npm
# or inside a project:
npm install --save-dev git-repo-npm
Usage
Adding a Git dependency
To add a Git dependency, you need to add a gitDependencies
object to your package.json
file. The keys of this object are the names of the dependencies, and the values are objects with the following properties:
source
- the URL of the Git repositorybranch
- the branch to use (optional, defaults tomaster
)package
- the path to the package directory (optional, defaults to the root of the repository)afterPull
- an array of shell commands to run after pulling the repository (optional)
For example, to add the grpm
repository as a dependency, you can add the following to your package.json
file:
{
"gitDependencies": {
"git-repo-npm": {
"source": "https://github.com/MrMaxie/GRPM",
"branch": "master"
}
}
}
Installing Git dependencies
To install Git dependencies or update existing ones, run the following command:
grpm
# or
git-repo-npm
Modules
Git dependencies are installed in the git_modules
directory. The directory structure is as follows:
git_modules
└── <dependency name>
├── <package directory>
│ └── package.json
└── .git
It's important to note that the package.json
file is located in the package directory. If "package" is not specified, the module will be not installed as a dependency, but will be still available in the git_modules
directory, will be updated and will run the afterPull
scripts.
AfterPull scripts
After pulling the repository, GRPM runs the afterPull
scripts. These scripts are specified as an array of shell commands in the afterPull
property of the dependency object. For example, to run npm install
after pulling the repository, you can add the following to your package.json
file:
{
"gitDependencies": {
"my-module": {
"source": "<url>",
"afterPull": [
"npm install",
"echo 'Done!'"
]
}
}
}
Debugging
To see more information about the installation process, you can run GRPM with the --debug
flag:
grpm --debug
Features
- Support for private repositories - strictly depends on the Git provider and the authentication method, but should work in the same way as with your terminal (e.g. if you use SSH keys, you don't need to do anything)
- Support for different branches - you can specify the branch to use in the
branch
property of the dependency object - Support for different package directories - you can specify the path to the package directory in the
package
property of the dependency object (relative to the root of the repository), or leave it empty to don't install the module as a dependency - Support for
afterPull
scripts - you can specify an array of shell commands to run after pulling the repository in theafterPull
property of the dependency object - Support for updating Git dependencies - GRPM will automatically pull the latest changes from the repository and run the
afterPull
scripts - Remove non-existent dependencies - if a dependency is removed from the
gitDependencies
object, GRPM will remove it from thegit_modules
directory on the next update - Support for multiple repositories from the same source - if you have multiple dependencies from the same repository, GRPM will only pull it once
- Support for selective pulling - if you want to ignore some files from the repository and only pull needed ones
- Support for proxy commands - if you want to run a command from the repository, e.g.
npm run build
without changing the current directory to the package directory - Support for selective installing & updating - if you want to install or update only some dependencies
- Support for commit hashes and tags - if you want to use a specific commit hash/tag to pull the repository, also allows to use hashes/tags as versioning method for dependencies
License (apache-2.0)
This project is licensed under the Apache License, Version 2.0. See LICENSE for more information.