@pubinfo/commitlint 2.0.0-rc.4 → 2.0.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.d.ts
CHANGED
|
@@ -26,8 +26,14 @@ interface PromptResult {
|
|
|
26
26
|
}
|
|
27
27
|
declare function runPrompt(): Promise<PromptResult | null>;
|
|
28
28
|
//#endregion
|
|
29
|
+
//#region src/utils/git.d.ts
|
|
30
|
+
/**
|
|
31
|
+
* 判断当前工作目录是否处在 Git 仓库内。
|
|
32
|
+
*/
|
|
33
|
+
declare function isInsideGitRepo(): boolean;
|
|
34
|
+
//#endregion
|
|
29
35
|
//#region src/utils/lint.message.d.ts
|
|
30
36
|
declare function lintMessage(message: string): Promise<boolean>;
|
|
31
37
|
declare function lintAndReturn(message: string): Promise<string>;
|
|
32
38
|
//#endregion
|
|
33
|
-
export { commitPreset, createCzConfig, createGitMessage, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
|
|
39
|
+
export { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { commitPreset, createCzConfig, createGitMessage, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-
|
|
1
|
+
import { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-CZXQspF4.js";
|
|
2
2
|
|
|
3
|
-
export { commitPreset, createCzConfig, createGitMessage, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
|
|
3
|
+
export { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
|
|
@@ -2317,6 +2317,24 @@ async function runPrompt() {
|
|
|
2317
2317
|
}
|
|
2318
2318
|
}
|
|
2319
2319
|
|
|
2320
|
+
//#endregion
|
|
2321
|
+
//#region src/utils/git.ts
|
|
2322
|
+
/**
|
|
2323
|
+
* 判断当前工作目录是否处在 Git 仓库内。
|
|
2324
|
+
*/
|
|
2325
|
+
function isInsideGitRepo() {
|
|
2326
|
+
try {
|
|
2327
|
+
const out = execSync("git rev-parse --is-inside-work-tree", { stdio: [
|
|
2328
|
+
"ignore",
|
|
2329
|
+
"pipe",
|
|
2330
|
+
"ignore"
|
|
2331
|
+
] });
|
|
2332
|
+
return String(out).trim() === "true";
|
|
2333
|
+
} catch {
|
|
2334
|
+
return false;
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2320
2338
|
//#endregion
|
|
2321
2339
|
//#region src/utils/lint.message.ts
|
|
2322
2340
|
async function lintMessage(message) {
|
|
@@ -2338,4 +2356,4 @@ async function lintAndReturn(message) {
|
|
|
2338
2356
|
}
|
|
2339
2357
|
|
|
2340
2358
|
//#endregion
|
|
2341
|
-
export { commitPreset, createCzConfig, createGitMessage, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
|
|
2359
|
+
export { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
|
package/dist/run.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createCzConfig, createGitMessage, lintMessage, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-
|
|
1
|
+
import { createCzConfig, createGitMessage, isInsideGitRepo, lintMessage, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-CZXQspF4.js";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { defineCommand, runMain as runMain$1 } from "citty";
|
|
@@ -6,7 +6,7 @@ import { defineCommand, runMain as runMain$1 } from "citty";
|
|
|
6
6
|
//#region package.json
|
|
7
7
|
var name = "@pubinfo/commitlint";
|
|
8
8
|
var type = "module";
|
|
9
|
-
var version = "2.0.0
|
|
9
|
+
var version = "2.0.0";
|
|
10
10
|
var description = "commitlint config for Pubinfo projects";
|
|
11
11
|
var exports = { ".": "./dist/index.js" };
|
|
12
12
|
var main$1 = "./dist/index.js";
|
|
@@ -15,6 +15,7 @@ var types = "./dist/index.d.ts";
|
|
|
15
15
|
var typesVersions = { "*": { "*": ["./dist/*", "./*"] } };
|
|
16
16
|
var bin = { "pubinfo-commit": "./bin/commit.js" };
|
|
17
17
|
var files = ["bin", "dist"];
|
|
18
|
+
var engines = { "node": "^20.19.0 || >=22.12.0" };
|
|
18
19
|
var scripts = {
|
|
19
20
|
"build": "tsdown",
|
|
20
21
|
"stub": "tsdown --watch"
|
|
@@ -38,6 +39,7 @@ var package_default = {
|
|
|
38
39
|
typesVersions,
|
|
39
40
|
bin,
|
|
40
41
|
files,
|
|
42
|
+
engines,
|
|
41
43
|
scripts,
|
|
42
44
|
dependencies
|
|
43
45
|
};
|
|
@@ -71,6 +73,10 @@ const main = defineCommand({
|
|
|
71
73
|
},
|
|
72
74
|
run: async ({ args }) => {
|
|
73
75
|
const { edit, init } = args;
|
|
76
|
+
if (!isInsideGitRepo()) {
|
|
77
|
+
console.error("[pubinfo-commit] 未检测到 Git 仓库。请在已初始化的 Git 项目中运行,或执行 `git init` 后重试。");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
74
80
|
if (init) {
|
|
75
81
|
const pubinfoDir = `${process.cwd()}/.pubinfo`;
|
|
76
82
|
if (!fs.existsSync(pubinfoDir)) fs.mkdirSync(pubinfoDir);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/commitlint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"description": "commitlint config for Pubinfo projects",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.js"
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"bin",
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
29
|
+
},
|
|
27
30
|
"dependencies": {
|
|
28
31
|
"@commitlint/config-conventional": "^19.8.1",
|
|
29
32
|
"@commitlint/lint": "^19.8.1",
|