@themranderson/gitpuller
v1.0.0
Published
A Node.js tool to pull updates for specified branches in multiple git repositories
Maintainers
Readme
GitPuller
A Node.js cross-platform CLI tool to automatically pull updates for specified development branches in multiple git repositories, configurable per repository.
Installation
- Ensure Node.js is installed.
- Clone or download this project.
- Run
npm installto install dependencies (including ESLint for linting).
Development
- Run
npm run lintto check code style with ESLint. - Run
npm run lint:fixto automatically fix linting issues. - The project uses
.editorconfigfor consistent formatting. Ensure your editor supports it.
Usage
After installing globally (npm install -g @themranderson/gitpuller), run:
gitpullerOr locally:
npm start
# or
node index.jsTo specify a custom config file:
gitpuller --config /path/to/my-config.jsonFor help:
gitpuller --helpPublishing
This package is automatically published to npm via GitHub Actions on pushes to the master branch as @themranderson/gitpuller. To set up publishing:
- Create an npm account if you don't have one.
- Generate an access token with publish permissions.
- Add the token as
NPM_TOKENin your repository's secrets (Settings > Secrets and variables > Actions).
Configuration
Edit config.json:
rootPath: The root directory containing your git repositories.repos: An object mapping repository folder names to their development branch names.additionalRepos(optional): An array of objects withpathandbranchfor repos outsiderootPath.switchToBranch(optional): Boolean, defaultfalse. Iftrue, switch to the configured branch if not already on it (with stashing and popping).
Example:
{
"rootPath": "/path/to/your/repos",
"switchToBranch": true,
"repos": {
"my-repo": "main",
"another-repo": "develop"
},
"additionalRepos": [
{
"path": "/full/path/to/repo/folder",
"branch": "main"
}
]
}Usage
Run the tool:
npm startOr:
node index.jsThe tool will:
- Scan for git repositories under
rootPath(up to depth 2). - For each repository listed in
repos, switch to the specified branch (stashing changes if necessary), pull updates if available, and switch back.
Behavior
- Only configured repositories are processed.
- If you're already on the development branch, it will pull if there are remote changes.
- If on a different branch, it stashes local changes, switches to the dev branch, pulls, switches back, and pops the stash.
- Errors are logged but don't stop processing other repos.
Cross-Platform
Works on Windows, Linux, and macOS, using Node.js built-in modules.
