smart-git-push
v1.1.5
Published
Auto commit message + push for JS/TS projects (Express, NestJS, React, React Native)
Downloads
430
Maintainers
Readme
smart-git-push
Auto commit message + git push for JavaScript and TypeScript projects:
- Express / Fastify APIs (
.tscontrollers & routes) - NestJS (
.controller.ts,.service.ts,.module.ts, decorators) - React (Vite, Next —
.tsxcomponents & pages) - React Native / Expo
- Plain Node / TypeScript scripts
Reads your diff, builds a useful commit subject + file list body, then pushes.
Install
In this monorepo (local)
{
"devDependencies": {
"smart-git-push": "file:./packages/smart-git-push"
},
"scripts": {
"push": "smart-git-push"
}
}npm install
npm run pushAny other project (npm link / publish)
npm install smart-git-push --save-dev
# or from git:
npm install github:YOUR_USER/YOUR_REPO#path:packages/smart-git-push{
"scripts": {
"push": "smart-git-push"
}
}Usage
npm run push
npm run push -- "fix login bug"
npx smart-git-push
npx smart-git-push --dry-run
npx smart-git-push --no-push
npx smart-git-push -m "release v2.1"Alias: sgp
Config (optional)
.smart-git-push.json in project root:
{
"branch": "main",
"remote": "origin",
"junkFiles": ["nul", "thumbs.db"],
"areaRules": [
{ "match": "/module/v3/", "area": "v3 API" },
{ "match": "\\.controller\\.ts$", "area": "Nest controllers" }
]
}Or in package.json:
{
"smartGitPush": {
"branch": "develop"
}
}TypeScript support
Works out of the box — no build step required. The CLI only reads git diff, not compiled output.
| Detects | Examples |
|---------|----------|
| Routes | router.get("/api"), app.post(), @Get(), @Post('users') |
| Exports | export async function, export const, export class |
| Types | export type, export interface, export enum |
| Paths | *.controller.ts, *.routes.ts, *.service.ts, *.dto.ts, tsconfig.json |
| Ignores | tsconfig.tsbuildinfo (junk file) |
TypeScript project setup
{
"scripts": { "push": "smart-git-push" },
"smartGitPush": {
"branch": "main",
"areaRules": [
{ "match": "module/v3/", "area": "v3 API" },
{ "match": "\\.controller\\.ts$", "area": "controllers" }
]
}
}Per stack
| Stack | What it detects |
|-------|-----------------|
| Express + TS | *.routes.ts, *.controllers.ts, Request, Response |
| NestJS | @Get(), @Post(), new *.controller.ts files |
| React + TS | components/, pages/, .tsx, vite.config.ts |
| React Native | screens/, expo, .native.tsx |
| TypeScript | tsconfig.json, types, interfaces, enums |
Programmatic API
const { smartGitPush, generateCommitMessage } = require("smart-git-push");
smartGitPush({ message: "optional manual subject" });
smartGitPush({ dryRun: true });Publish to npm
From the smart-git-push repo root:
npm login
npm publish --access publicThen in any project:
npm i -D smart-git-pushInstall from npm (after publish)
npm i -D smart-git-push{
"scripts": { "push": "smart-git-push" }
}