git-quickcommit-cli 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/bin/qc.js +105 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# quickcommit
|
|
2
|
+
|
|
3
|
+
A global CLI utility that executes your full Git cycle with one command: `git add .`, `git commit -m`, and `git push`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g git-quickcommit-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
qc "your commit message"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
When you run:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
qc "update login flow"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
it executes this flow:
|
|
26
|
+
|
|
27
|
+
1. `git add .`
|
|
28
|
+
2. `git commit -m "update login flow"`
|
|
29
|
+
3. `git push` (or `git push --set-upstream origin <branch>` if upstream is missing)
|
|
30
|
+
|
|
31
|
+
## `bin/qc.js` Logic
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
qc "commit message"
|
|
35
|
+
|
|
|
36
|
+
+--> commit message provided?
|
|
37
|
+
| +--> no -> error and exit
|
|
38
|
+
| +--> yes
|
|
39
|
+
|
|
|
40
|
+
+--> inside a git repository?
|
|
41
|
+
| +--> no -> error and exit
|
|
42
|
+
| +--> yes
|
|
43
|
+
|
|
|
44
|
+
+--> detect current branch
|
|
45
|
+
+--> upstream exists?
|
|
46
|
+
+--> yes:
|
|
47
|
+
| +--> git fetch
|
|
48
|
+
| +--> local branch behind remote?
|
|
49
|
+
| +--> yes -> "update branch first" and exit
|
|
50
|
+
| +--> no -> continue
|
|
51
|
+
|
|
|
52
|
+
+--> no:
|
|
53
|
+
+--> continue
|
|
54
|
+
|
|
|
55
|
+
+--> git add .
|
|
56
|
+
+--> git commit -m "message"
|
|
57
|
+
+--> upstream exists?
|
|
58
|
+
+--> yes -> git push
|
|
59
|
+
+--> no -> git push --set-upstream origin <branch>
|
|
60
|
+
|
|
|
61
|
+
+--> done
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Command sequence used internally:
|
|
65
|
+
|
|
66
|
+
1. `git rev-parse --is-inside-work-tree`
|
|
67
|
+
2. `git rev-parse --abbrev-ref HEAD`
|
|
68
|
+
3. `git rev-parse --abbrev-ref --symbolic-full-name @{u}`
|
|
69
|
+
4. If upstream exists: `git fetch`
|
|
70
|
+
5. If upstream exists: `git rev-list --left-right --count HEAD...@{u}` (block when behind remote)
|
|
71
|
+
6. `git add .`
|
|
72
|
+
7. `git commit -m "your message"`
|
|
73
|
+
8. `git push` or `git push --set-upstream origin <branch>`
|
|
74
|
+
|
|
75
|
+
## Requirements
|
|
76
|
+
|
|
77
|
+
- Node.js 14+
|
|
78
|
+
- Git installed and available in PATH
|
|
79
|
+
|
|
80
|
+
## Notes
|
|
81
|
+
|
|
82
|
+
- Run `qc` only inside a git repository.
|
|
83
|
+
- If your local branch is behind remote, `qc` stops and asks you to update the branch first.
|
|
84
|
+
- If `git commit` fails (for example, no changes staged), the process stops and prints the git error.
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT
|
|
89
|
+
|
|
90
|
+
## Repository
|
|
91
|
+
|
|
92
|
+
https://github.com/vanholler/quickcommit.git
|
package/bin/qc.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const COLORS = {
|
|
6
|
+
reset: '\x1b[0m',
|
|
7
|
+
green: '\x1b[32m',
|
|
8
|
+
yellow: '\x1b[33m',
|
|
9
|
+
red: '\x1b[31m',
|
|
10
|
+
cyan: '\x1b[36m'
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function logInfo(message) {
|
|
14
|
+
console.log(`${COLORS.cyan}${message}${COLORS.reset}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function logSuccess(message) {
|
|
18
|
+
console.log(`${COLORS.green}${message}${COLORS.reset}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function logWarn(message) {
|
|
22
|
+
console.log(`${COLORS.yellow}${message}${COLORS.reset}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function logError(message) {
|
|
26
|
+
console.error(`${COLORS.red}${message}${COLORS.reset}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function run(command, options = {}) {
|
|
30
|
+
return execSync(command, {
|
|
31
|
+
stdio: options.capture ? 'pipe' : 'inherit',
|
|
32
|
+
encoding: 'utf8'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function safeRun(command) {
|
|
37
|
+
try {
|
|
38
|
+
return run(command, { capture: true }).trim();
|
|
39
|
+
} catch (_error) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function main() {
|
|
45
|
+
const message = process.argv.slice(2).join(' ').trim();
|
|
46
|
+
|
|
47
|
+
if (!message) {
|
|
48
|
+
logError('Error: please provide a commit message. Example: qc "my message"');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const insideRepo = safeRun('git rev-parse --is-inside-work-tree');
|
|
53
|
+
if (insideRepo !== 'true') {
|
|
54
|
+
logError('Error: current directory is not a git repository.');
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const branch = safeRun('git rev-parse --abbrev-ref HEAD');
|
|
60
|
+
if (!branch || branch === 'HEAD') {
|
|
61
|
+
logError('Error: unable to determine current branch.');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const upstream = safeRun('git rev-parse --abbrev-ref --symbolic-full-name @{u}');
|
|
66
|
+
if (upstream) {
|
|
67
|
+
logInfo('Checking remote updates: git fetch');
|
|
68
|
+
run('git fetch');
|
|
69
|
+
|
|
70
|
+
const counts = safeRun('git rev-list --left-right --count HEAD...@{u}');
|
|
71
|
+
const parts = counts ? counts.split(/\s+/) : [];
|
|
72
|
+
const behind = Number(parts[1] || 0);
|
|
73
|
+
|
|
74
|
+
if (behind > 0) {
|
|
75
|
+
logError('Error: local branch is behind remote. Сначала обновите ветку.');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
logInfo('1/3 Running: git add .');
|
|
81
|
+
run('git add .');
|
|
82
|
+
|
|
83
|
+
logInfo(`2/3 Running: git commit -m "${message}"`);
|
|
84
|
+
run(`git commit -m ${JSON.stringify(message)}`);
|
|
85
|
+
|
|
86
|
+
if (upstream) {
|
|
87
|
+
logInfo('3/3 Running: git push');
|
|
88
|
+
run('git push');
|
|
89
|
+
} else {
|
|
90
|
+
logWarn(`No upstream for branch "${branch}". Setting upstream to origin/${branch}.`);
|
|
91
|
+
logInfo(`3/3 Running: git push --set-upstream origin ${branch}`);
|
|
92
|
+
run(`git push --set-upstream origin ${branch}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
logSuccess('Done: changes added, committed, and pushed successfully.');
|
|
96
|
+
} catch (error) {
|
|
97
|
+
logError('Failed: command execution stopped due to an error.');
|
|
98
|
+
if (error && error.message) {
|
|
99
|
+
logError(error.message);
|
|
100
|
+
}
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "git-quickcommit-cli",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Run git add, commit, and push in one command from the terminal.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "vanholler",
|
|
7
|
+
"email": "vanholler@mail.ru",
|
|
8
|
+
"url": "https://github.com/vanholler"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/vanholler/quickcommit#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/vanholler/quickcommit.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/vanholler/quickcommit/issues"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"qc": "bin/qc.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start": "node ./bin/qc.js",
|
|
28
|
+
"pack:check": "npm pack --dry-run"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"git",
|
|
32
|
+
"commit",
|
|
33
|
+
"push",
|
|
34
|
+
"automation",
|
|
35
|
+
"quickcommit",
|
|
36
|
+
"cli",
|
|
37
|
+
"productivity"
|
|
38
|
+
],
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=14"
|
|
42
|
+
}
|
|
43
|
+
}
|