@commitguard/cli 0.0.2 → 0.0.13
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.mts +0 -0
- package/dist/index.mjs +22 -15
- package/package.json +13 -11
package/dist/index.d.mts
CHANGED
|
File without changes
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
import process from "node:process";
|
|
4
3
|
import { consola } from "consola";
|
|
5
4
|
import updateNotifier from "update-notifier";
|
|
@@ -10,19 +9,15 @@ import { Entry } from "@napi-rs/keyring";
|
|
|
10
9
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
11
10
|
import { homedir } from "node:os";
|
|
12
11
|
import { dirname, join } from "node:path";
|
|
12
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
13
13
|
import { readFile } from "node:fs/promises";
|
|
14
|
-
import { pathToFileURL } from "node:url";
|
|
15
14
|
import { findUp } from "find-up";
|
|
16
15
|
import { FlatCache } from "flat-cache";
|
|
17
16
|
import stringWidth from "string-width";
|
|
18
17
|
import "dotenv/config";
|
|
19
18
|
|
|
20
|
-
//#region rolldown:runtime
|
|
21
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
19
|
//#region package.json
|
|
25
|
-
var version = "0.0.
|
|
20
|
+
var version = "0.0.13";
|
|
26
21
|
var package_default = {
|
|
27
22
|
name: "@commitguard/cli",
|
|
28
23
|
type: "module",
|
|
@@ -31,7 +26,7 @@ var package_default = {
|
|
|
31
26
|
license: "MIT",
|
|
32
27
|
repository: {
|
|
33
28
|
"type": "git",
|
|
34
|
-
"url": "git+https://github.com/
|
|
29
|
+
"url": "git+https://github.com/commitguard/cli.git"
|
|
35
30
|
},
|
|
36
31
|
exports: {
|
|
37
32
|
".": "./dist/index.mjs",
|
|
@@ -49,7 +44,8 @@ var package_default = {
|
|
|
49
44
|
"typecheck": "tsc --noEmit",
|
|
50
45
|
"prepublishOnly": "pnpm run build",
|
|
51
46
|
"lint": "eslint .",
|
|
52
|
-
"lint:fix": "eslint . --fix"
|
|
47
|
+
"lint:fix": "eslint . --fix",
|
|
48
|
+
"release": "pnpm typecheck && bumpp --tag --push --publish && npm publish"
|
|
53
49
|
},
|
|
54
50
|
dependencies: {
|
|
55
51
|
"@clack/prompts": "^0.11.0",
|
|
@@ -370,7 +366,13 @@ async function sendToCommitGuard(diff, eslint, config) {
|
|
|
370
366
|
});
|
|
371
367
|
if (!response.ok) {
|
|
372
368
|
const errorText = await response.text();
|
|
373
|
-
|
|
369
|
+
let errorMessage = "Failed to analyze commit";
|
|
370
|
+
if (response.status === 401) errorMessage = "Invalid API key. Check your key with \"commitguard keys\" or get a new one at https://commitguard.ai";
|
|
371
|
+
else if (response.status === 429) errorMessage = "Rate limit exceeded. Please try again later";
|
|
372
|
+
else if (response.status === 500) errorMessage = "CommitGuard service error. Please try again later";
|
|
373
|
+
else if (response.status >= 400 && response.status < 500) errorMessage = `Request error: ${errorText || "Invalid request"}`;
|
|
374
|
+
else errorMessage = `Service unavailable (${response.status}). Please try again later`;
|
|
375
|
+
throw new Error(errorMessage);
|
|
374
376
|
}
|
|
375
377
|
return await response.json();
|
|
376
378
|
}
|
|
@@ -420,7 +422,7 @@ function getDefaultConfig() {
|
|
|
420
422
|
severityLevels: {
|
|
421
423
|
critical: true,
|
|
422
424
|
warning: true,
|
|
423
|
-
suggestion:
|
|
425
|
+
suggestion: false
|
|
424
426
|
},
|
|
425
427
|
customRule: ""
|
|
426
428
|
};
|
|
@@ -735,7 +737,7 @@ async function installHooks() {
|
|
|
735
737
|
}
|
|
736
738
|
log.info("Installing CommitGuard...");
|
|
737
739
|
const node = process.execPath.replace(/\\/g, "/");
|
|
738
|
-
const cliPath =
|
|
740
|
+
const cliPath = fileURLToPath(import.meta.url).replace(/\\/g, "/");
|
|
739
741
|
writeFileSync(COMMIT_MSG_HOOK_PATH, `#!/bin/sh
|
|
740
742
|
${COMMITGUARD_MARKER}
|
|
741
743
|
# Auto-generated - do not edit manually
|
|
@@ -784,9 +786,14 @@ fi
|
|
|
784
786
|
|
|
785
787
|
exit 0
|
|
786
788
|
`, { mode: 493 });
|
|
787
|
-
log.info("
|
|
788
|
-
|
|
789
|
-
|
|
789
|
+
log.info("Checking ESLint configuration...");
|
|
790
|
+
try {
|
|
791
|
+
const eslintRules = await getEslintRules({ overrideCache: true });
|
|
792
|
+
if (Object.keys(eslintRules.rules).length > 0) log.success("ESLint configuration loaded.");
|
|
793
|
+
else log.info("No ESLint rules detected.");
|
|
794
|
+
} catch {
|
|
795
|
+
log.warn("Failed to load ESLint configuration.");
|
|
796
|
+
}
|
|
790
797
|
if (!getGlobalKey() && process.env.COMMITGUARD_API_KEY === void 0) {
|
|
791
798
|
if (await confirm({
|
|
792
799
|
message: "No global API key found. Do you want to set it now?",
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitguard/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.13",
|
|
5
5
|
"description": "AI-powered git commit checker that blocks bad code before it ships",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/commitguard/cli.git"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./dist/index.mjs",
|
|
@@ -21,6 +21,16 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsdown",
|
|
26
|
+
"dev": "tsdown --watch",
|
|
27
|
+
"test": "vitest",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"prepublishOnly": "pnpm run build",
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"lint:fix": "eslint . --fix",
|
|
32
|
+
"release": "pnpm typecheck && bumpp --tag --push --publish && npm publish"
|
|
33
|
+
},
|
|
24
34
|
"dependencies": {
|
|
25
35
|
"@clack/prompts": "^0.11.0",
|
|
26
36
|
"@napi-rs/keyring": "^1.2.0",
|
|
@@ -42,13 +52,5 @@
|
|
|
42
52
|
"tsdown": "^0.18.3",
|
|
43
53
|
"typescript": "^5.9.3",
|
|
44
54
|
"vitest": "^4.0.16"
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "tsdown",
|
|
48
|
-
"dev": "tsdown --watch",
|
|
49
|
-
"test": "vitest",
|
|
50
|
-
"typecheck": "tsc --noEmit",
|
|
51
|
-
"lint": "eslint .",
|
|
52
|
-
"lint:fix": "eslint . --fix"
|
|
53
55
|
}
|
|
54
|
-
}
|
|
56
|
+
}
|