@quikcommit/cli 11.0.0 → 11.1.0
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/dist/index.js +60 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -89,9 +89,14 @@ function slugifyFilename(path) {
|
|
|
89
89
|
const noExt = basename.replace(/\.[^.]+$/, "");
|
|
90
90
|
return noExt.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
|
|
91
91
|
}
|
|
92
|
+
function pickBestFile(files) {
|
|
93
|
+
const codeFiles = files.filter((f) => !NON_CODE_PATTERNS.some((rx) => rx.test(f)));
|
|
94
|
+
return codeFiles[0] ?? files[0] ?? "";
|
|
95
|
+
}
|
|
92
96
|
function deterministicBranchName(opts) {
|
|
93
97
|
const files = opts.files ?? [];
|
|
94
|
-
const
|
|
98
|
+
const codeFiles = files.filter((f) => !NON_CODE_PATTERNS.some((rx) => rx.test(f)));
|
|
99
|
+
const haystack = `${opts.description ?? ""} ${(codeFiles.length > 0 ? codeFiles : files).join(" ")}`;
|
|
95
100
|
let type = "chore";
|
|
96
101
|
for (const [rx, t] of TYPE_HINTS) {
|
|
97
102
|
if (rx.test(haystack)) {
|
|
@@ -103,7 +108,7 @@ function deterministicBranchName(opts) {
|
|
|
103
108
|
if (opts.description) {
|
|
104
109
|
slug = opts.description.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").split("-").slice(0, 5).join("-").slice(0, 40);
|
|
105
110
|
} else if (files.length > 0) {
|
|
106
|
-
slug = slugifyFilename(files
|
|
111
|
+
slug = slugifyFilename(pickBestFile(files));
|
|
107
112
|
} else {
|
|
108
113
|
slug = "changes";
|
|
109
114
|
}
|
|
@@ -117,7 +122,7 @@ function deterministicBranchName(opts) {
|
|
|
117
122
|
}
|
|
118
123
|
return { name, type, slug };
|
|
119
124
|
}
|
|
120
|
-
var BRANCH_NAME_RX, PROTECTED_BRANCH_RX, MAX_BRANCH_NAME_LENGTH, TYPE_HINTS;
|
|
125
|
+
var BRANCH_NAME_RX, PROTECTED_BRANCH_RX, MAX_BRANCH_NAME_LENGTH, TYPE_HINTS, NON_CODE_PATTERNS;
|
|
121
126
|
var init_branch = __esm({
|
|
122
127
|
"../shared/dist/branch.js"() {
|
|
123
128
|
"use strict";
|
|
@@ -133,6 +138,21 @@ var init_branch = __esm({
|
|
|
133
138
|
[/\bfix|bug|issue/i, "fix"],
|
|
134
139
|
[/\bfeat|add|new\b/i, "feat"]
|
|
135
140
|
];
|
|
141
|
+
NON_CODE_PATTERNS = [
|
|
142
|
+
/^docs?\//i,
|
|
143
|
+
/^\.env/,
|
|
144
|
+
/\.md$/i,
|
|
145
|
+
/^readme/i,
|
|
146
|
+
/^changelog/i,
|
|
147
|
+
/^license/i,
|
|
148
|
+
/\.lock$/,
|
|
149
|
+
/\.ya?ml$/,
|
|
150
|
+
/\.json$/,
|
|
151
|
+
/\.toml$/,
|
|
152
|
+
/\/\.?config\b/i,
|
|
153
|
+
/^\.github\//,
|
|
154
|
+
/^\.vscode\//
|
|
155
|
+
];
|
|
136
156
|
}
|
|
137
157
|
});
|
|
138
158
|
|
|
@@ -7975,8 +7995,18 @@ function gitCommit(message) {
|
|
|
7975
7995
|
}
|
|
7976
7996
|
}
|
|
7977
7997
|
function gitPush() {
|
|
7998
|
+
const branch = (0, import_child_process2.execFileSync)("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
7999
|
+
encoding: "utf-8"
|
|
8000
|
+
}).trim();
|
|
8001
|
+
let hasUpstream = false;
|
|
8002
|
+
try {
|
|
8003
|
+
(0, import_child_process2.execFileSync)("git", ["rev-parse", "--abbrev-ref", `${branch}@{upstream}`], { stdio: "pipe" });
|
|
8004
|
+
hasUpstream = true;
|
|
8005
|
+
} catch {
|
|
8006
|
+
}
|
|
8007
|
+
const args = hasUpstream ? ["push"] : ["push", "--set-upstream", "origin", branch];
|
|
7978
8008
|
try {
|
|
7979
|
-
(0, import_child_process2.execFileSync)("git",
|
|
8009
|
+
(0, import_child_process2.execFileSync)("git", args, { stdio: "pipe" });
|
|
7980
8010
|
} catch (err) {
|
|
7981
8011
|
const stderr = err?.stderr?.toString() ?? "";
|
|
7982
8012
|
if (stderr) process.stderr.write(stderr);
|
|
@@ -8091,19 +8121,36 @@ function getPushStats() {
|
|
|
8091
8121
|
const branch = (0, import_child_process2.execFileSync)("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
8092
8122
|
encoding: "utf-8"
|
|
8093
8123
|
}).trim();
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8124
|
+
let upstream = null;
|
|
8125
|
+
try {
|
|
8126
|
+
upstream = (0, import_child_process2.execFileSync)(
|
|
8127
|
+
"git",
|
|
8128
|
+
["rev-parse", "--abbrev-ref", `${branch}@{upstream}`],
|
|
8129
|
+
{ encoding: "utf-8", stdio: "pipe" }
|
|
8130
|
+
).trim();
|
|
8131
|
+
} catch {
|
|
8132
|
+
}
|
|
8133
|
+
if (upstream) {
|
|
8134
|
+
const countOutput = (0, import_child_process2.execFileSync)(
|
|
8135
|
+
"git",
|
|
8136
|
+
["rev-list", "--count", `${upstream}..HEAD`],
|
|
8137
|
+
{ encoding: "utf-8" }
|
|
8138
|
+
).trim();
|
|
8139
|
+
const parsedCount = parseInt(countOutput, 10);
|
|
8140
|
+
const commits = Number.isFinite(parsedCount) ? parsedCount : 0;
|
|
8141
|
+
const stat2 = (0, import_child_process2.execFileSync)(
|
|
8142
|
+
"git",
|
|
8143
|
+
["diff", "--shortstat", `${upstream}..HEAD`],
|
|
8144
|
+
{ encoding: "utf-8" }
|
|
8145
|
+
).trim();
|
|
8146
|
+
return { commits, stat: stat2 };
|
|
8147
|
+
}
|
|
8101
8148
|
const stat = (0, import_child_process2.execFileSync)(
|
|
8102
8149
|
"git",
|
|
8103
|
-
["diff", "--shortstat",
|
|
8150
|
+
["diff", "--shortstat", "HEAD~1..HEAD"],
|
|
8104
8151
|
{ encoding: "utf-8" }
|
|
8105
8152
|
).trim();
|
|
8106
|
-
return { commits, stat };
|
|
8153
|
+
return { commits: 1, stat };
|
|
8107
8154
|
} catch {
|
|
8108
8155
|
return null;
|
|
8109
8156
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quikcommit/cli",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "AI-powered conventional commit messages",
|
|
5
5
|
"bin": {
|
|
6
6
|
"qc": "./dist/index.js"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"esbuild": "^0.28.0",
|
|
35
35
|
"typescript": "^5.9.3",
|
|
36
36
|
"vitest": "^4.1.5",
|
|
37
|
-
"@quikcommit/shared": "8.
|
|
37
|
+
"@quikcommit/shared": "8.1.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "node build.mjs",
|