@m3hti/commit-genie 1.2.5 → 1.2.7
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/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +31 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/generate.d.ts +12 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +550 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/generate.test.d.ts +2 -0
- package/dist/commands/generate.test.d.ts.map +1 -0
- package/dist/commands/generate.test.js +168 -0
- package/dist/commands/generate.test.js.map +1 -0
- package/dist/commands/hook.d.ts +4 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +62 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/stats.d.ts +6 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +39 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/data/wordlist.d.ts +11 -0
- package/dist/data/wordlist.d.ts.map +1 -0
- package/dist/data/wordlist.js +170 -0
- package/dist/data/wordlist.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/services/aiService.d.ts +42 -0
- package/dist/services/aiService.d.ts.map +1 -0
- package/dist/services/aiService.js +224 -0
- package/dist/services/aiService.js.map +1 -0
- package/dist/services/analyzerService.d.ts +139 -0
- package/dist/services/analyzerService.d.ts.map +1 -0
- package/dist/services/analyzerService.js +1811 -0
- package/dist/services/analyzerService.js.map +1 -0
- package/dist/services/analyzerService.test.d.ts +2 -0
- package/dist/services/analyzerService.test.d.ts.map +1 -0
- package/dist/services/analyzerService.test.js +577 -0
- package/dist/services/analyzerService.test.js.map +1 -0
- package/dist/services/configService.d.ts +25 -0
- package/dist/services/configService.d.ts.map +1 -0
- package/dist/services/configService.js +228 -0
- package/dist/services/configService.js.map +1 -0
- package/dist/services/configService.test.d.ts +2 -0
- package/dist/services/configService.test.d.ts.map +1 -0
- package/dist/services/configService.test.js +165 -0
- package/dist/services/configService.test.js.map +1 -0
- package/dist/services/gitService.d.ts +64 -0
- package/dist/services/gitService.d.ts.map +1 -0
- package/dist/services/gitService.js +303 -0
- package/dist/services/gitService.js.map +1 -0
- package/dist/services/gitService.test.d.ts +2 -0
- package/dist/services/gitService.test.d.ts.map +1 -0
- package/dist/services/gitService.test.js +140 -0
- package/dist/services/gitService.test.js.map +1 -0
- package/dist/services/historyService.d.ts +39 -0
- package/dist/services/historyService.d.ts.map +1 -0
- package/dist/services/historyService.js +195 -0
- package/dist/services/historyService.js.map +1 -0
- package/dist/services/historyService.test.d.ts +2 -0
- package/dist/services/historyService.test.d.ts.map +1 -0
- package/dist/services/historyService.test.js +157 -0
- package/dist/services/historyService.test.js.map +1 -0
- package/dist/services/hookService.d.ts +29 -0
- package/dist/services/hookService.d.ts.map +1 -0
- package/dist/services/hookService.js +164 -0
- package/dist/services/hookService.js.map +1 -0
- package/dist/services/lintService.d.ts +32 -0
- package/dist/services/lintService.d.ts.map +1 -0
- package/dist/services/lintService.js +191 -0
- package/dist/services/lintService.js.map +1 -0
- package/dist/services/spellService.d.ts +42 -0
- package/dist/services/spellService.d.ts.map +1 -0
- package/dist/services/spellService.js +175 -0
- package/dist/services/spellService.js.map +1 -0
- package/dist/services/splitService.d.ts +32 -0
- package/dist/services/splitService.d.ts.map +1 -0
- package/dist/services/splitService.js +184 -0
- package/dist/services/splitService.js.map +1 -0
- package/dist/services/statsService.d.ts +28 -0
- package/dist/services/statsService.d.ts.map +1 -0
- package/dist/services/statsService.js +204 -0
- package/dist/services/statsService.js.map +1 -0
- package/dist/types/index.d.ts +222 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/filePatterns.d.ts +5 -0
- package/dist/utils/filePatterns.d.ts.map +1 -0
- package/dist/utils/filePatterns.js +77 -0
- package/dist/utils/filePatterns.js.map +1 -0
- package/dist/utils/filePatterns.test.d.ts +2 -0
- package/dist/utils/filePatterns.test.d.ts.map +1 -0
- package/dist/utils/filePatterns.test.js +51 -0
- package/dist/utils/filePatterns.test.js.map +1 -0
- package/dist/utils/prompt.d.ts +4 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +60 -0
- package/dist/utils/prompt.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConfigService = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const gitService_1 = require("./gitService");
|
|
40
|
+
const CONFIG_FILES = [
|
|
41
|
+
'.commitgenierc.json',
|
|
42
|
+
'.commitgenierc',
|
|
43
|
+
'commitgenie.config.json',
|
|
44
|
+
];
|
|
45
|
+
const DEFAULT_CONFIG = {
|
|
46
|
+
scopes: [],
|
|
47
|
+
defaultType: 'feat',
|
|
48
|
+
includeEmoji: undefined, // Let history learning decide
|
|
49
|
+
maxMessageLength: 72,
|
|
50
|
+
customPatterns: [],
|
|
51
|
+
ticketLinking: {
|
|
52
|
+
enabled: true,
|
|
53
|
+
prefix: 'Refs:',
|
|
54
|
+
},
|
|
55
|
+
learnFromHistory: {
|
|
56
|
+
enabled: true,
|
|
57
|
+
commitCount: 50,
|
|
58
|
+
},
|
|
59
|
+
breakingChangeDetection: {
|
|
60
|
+
enabled: true,
|
|
61
|
+
includeFooter: true,
|
|
62
|
+
},
|
|
63
|
+
templates: {
|
|
64
|
+
default: '{emoji} {type}({scope}): {description}',
|
|
65
|
+
noScope: '{emoji} {type}: {description}',
|
|
66
|
+
withBody: '{emoji} {type}({scope}): {description}\n\n{body}',
|
|
67
|
+
},
|
|
68
|
+
ai: {
|
|
69
|
+
enabled: false,
|
|
70
|
+
provider: 'openai',
|
|
71
|
+
model: 'gpt-4o-mini',
|
|
72
|
+
},
|
|
73
|
+
linting: {
|
|
74
|
+
enabled: true,
|
|
75
|
+
blockOnError: true,
|
|
76
|
+
rules: {
|
|
77
|
+
subjectMaxLength: { enabled: true, maxLength: 72 },
|
|
78
|
+
typeRequired: { enabled: true },
|
|
79
|
+
scopeFormat: { enabled: true },
|
|
80
|
+
imperativeMood: { enabled: true },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
splitting: {
|
|
84
|
+
enabled: true,
|
|
85
|
+
minFilesForSuggestion: 2,
|
|
86
|
+
groupByScope: true,
|
|
87
|
+
groupByType: true,
|
|
88
|
+
},
|
|
89
|
+
spellCheck: {
|
|
90
|
+
enabled: true,
|
|
91
|
+
customDictionary: [],
|
|
92
|
+
ignorePatterns: [],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
class ConfigService {
|
|
96
|
+
/**
|
|
97
|
+
* Find and load the config file
|
|
98
|
+
*/
|
|
99
|
+
static loadConfig() {
|
|
100
|
+
if (this.cachedConfig) {
|
|
101
|
+
return this.cachedConfig;
|
|
102
|
+
}
|
|
103
|
+
let configPath = null;
|
|
104
|
+
// Try to find config in git root first
|
|
105
|
+
try {
|
|
106
|
+
const gitRoot = gitService_1.GitService.getGitRoot();
|
|
107
|
+
for (const filename of CONFIG_FILES) {
|
|
108
|
+
const fullPath = path.join(gitRoot, filename);
|
|
109
|
+
if (fs.existsSync(fullPath)) {
|
|
110
|
+
configPath = fullPath;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Not in a git repo, try current directory
|
|
117
|
+
}
|
|
118
|
+
// Fallback to current directory
|
|
119
|
+
if (!configPath) {
|
|
120
|
+
for (const filename of CONFIG_FILES) {
|
|
121
|
+
const fullPath = path.join(process.cwd(), filename);
|
|
122
|
+
if (fs.existsSync(fullPath)) {
|
|
123
|
+
configPath = fullPath;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!configPath) {
|
|
129
|
+
this.cachedConfig = DEFAULT_CONFIG;
|
|
130
|
+
return DEFAULT_CONFIG;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
134
|
+
const userConfig = JSON.parse(content);
|
|
135
|
+
this.cachedConfig = { ...DEFAULT_CONFIG, ...userConfig };
|
|
136
|
+
return this.cachedConfig;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
console.warn(`Warning: Failed to parse config file: ${configPath}`);
|
|
140
|
+
this.cachedConfig = DEFAULT_CONFIG;
|
|
141
|
+
return DEFAULT_CONFIG;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get the current config
|
|
146
|
+
*/
|
|
147
|
+
static getConfig() {
|
|
148
|
+
return this.loadConfig();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Clear the cached config (useful for testing)
|
|
152
|
+
*/
|
|
153
|
+
static clearCache() {
|
|
154
|
+
this.cachedConfig = null;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Create a default config file
|
|
158
|
+
*/
|
|
159
|
+
static initConfig() {
|
|
160
|
+
try {
|
|
161
|
+
let targetDir;
|
|
162
|
+
try {
|
|
163
|
+
targetDir = gitService_1.GitService.getGitRoot();
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
targetDir = process.cwd();
|
|
167
|
+
}
|
|
168
|
+
const configPath = path.join(targetDir, '.commitgenierc.json');
|
|
169
|
+
if (fs.existsSync(configPath)) {
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
message: 'Config file already exists',
|
|
173
|
+
path: configPath,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const sampleConfig = {
|
|
177
|
+
scopes: [
|
|
178
|
+
{ pattern: 'src/api', scope: 'api' },
|
|
179
|
+
{ pattern: 'src/components', scope: 'ui' },
|
|
180
|
+
{ pattern: 'src/utils', scope: 'utils' },
|
|
181
|
+
],
|
|
182
|
+
defaultType: 'feat',
|
|
183
|
+
includeEmoji: true,
|
|
184
|
+
maxMessageLength: 72,
|
|
185
|
+
customPatterns: [],
|
|
186
|
+
ticketLinking: {
|
|
187
|
+
enabled: true,
|
|
188
|
+
patterns: ['[A-Z]{2,10}-\\d+', '#\\d+'],
|
|
189
|
+
prefix: 'Refs:',
|
|
190
|
+
},
|
|
191
|
+
learnFromHistory: {
|
|
192
|
+
enabled: true,
|
|
193
|
+
commitCount: 50,
|
|
194
|
+
},
|
|
195
|
+
breakingChangeDetection: {
|
|
196
|
+
enabled: true,
|
|
197
|
+
keywords: ['breaking', 'removed', 'deleted', 'deprecated'],
|
|
198
|
+
includeFooter: true,
|
|
199
|
+
},
|
|
200
|
+
templates: {
|
|
201
|
+
default: '{emoji} {type}({scope}): {description}',
|
|
202
|
+
noScope: '{emoji} {type}: {description}',
|
|
203
|
+
withBody: '{emoji} {type}({scope}): {description}\n\n{body}',
|
|
204
|
+
},
|
|
205
|
+
ai: {
|
|
206
|
+
enabled: false,
|
|
207
|
+
provider: 'openai',
|
|
208
|
+
model: 'gpt-4o-mini',
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
fs.writeFileSync(configPath, JSON.stringify(sampleConfig, null, 2));
|
|
212
|
+
return {
|
|
213
|
+
success: true,
|
|
214
|
+
message: 'Config file created',
|
|
215
|
+
path: configPath,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
return {
|
|
220
|
+
success: false,
|
|
221
|
+
message: `Failed to create config: ${error instanceof Error ? error.message : error}`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.ConfigService = ConfigService;
|
|
227
|
+
ConfigService.cachedConfig = null;
|
|
228
|
+
//# sourceMappingURL=configService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configService.js","sourceRoot":"","sources":["../../src/services/configService.ts"],"names":[],"mappings":";;;;;;;;;;;;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","sources":["../../src/services/configService.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const configService_1 = require("./configService");
|
|
38
|
+
const gitService_1 = require("./gitService");
|
|
39
|
+
// Mock dependencies
|
|
40
|
+
jest.mock('fs');
|
|
41
|
+
jest.mock('./gitService');
|
|
42
|
+
const mockedFs = fs;
|
|
43
|
+
const mockedGitService = gitService_1.GitService;
|
|
44
|
+
describe('ConfigService', () => {
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
jest.clearAllMocks();
|
|
47
|
+
configService_1.ConfigService.clearCache();
|
|
48
|
+
});
|
|
49
|
+
describe('loadConfig', () => {
|
|
50
|
+
it('should return default config when no config file exists', () => {
|
|
51
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
52
|
+
mockedFs.existsSync.mockReturnValue(false);
|
|
53
|
+
const config = configService_1.ConfigService.loadConfig();
|
|
54
|
+
expect(config.defaultType).toBe('feat');
|
|
55
|
+
expect(config.maxMessageLength).toBe(72);
|
|
56
|
+
expect(config.includeEmoji).toBeUndefined(); // Let history learning decide
|
|
57
|
+
expect(config.scopes).toEqual([]);
|
|
58
|
+
expect(config.ticketLinking?.enabled).toBe(true);
|
|
59
|
+
expect(config.learnFromHistory?.enabled).toBe(true);
|
|
60
|
+
expect(config.breakingChangeDetection?.enabled).toBe(true);
|
|
61
|
+
expect(config.breakingChangeDetection?.includeFooter).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
it('should load config from .commitgenierc.json', () => {
|
|
64
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
65
|
+
mockedFs.existsSync.mockImplementation((filePath) => {
|
|
66
|
+
return String(filePath).includes('.commitgenierc.json');
|
|
67
|
+
});
|
|
68
|
+
mockedFs.readFileSync.mockReturnValue(JSON.stringify({
|
|
69
|
+
scopes: [{ pattern: 'src/api', scope: 'api' }],
|
|
70
|
+
defaultType: 'fix',
|
|
71
|
+
}));
|
|
72
|
+
const config = configService_1.ConfigService.loadConfig();
|
|
73
|
+
expect(config.defaultType).toBe('fix');
|
|
74
|
+
expect(config.scopes).toHaveLength(1);
|
|
75
|
+
expect(config.scopes[0].scope).toBe('api');
|
|
76
|
+
});
|
|
77
|
+
it('should merge user config with defaults', () => {
|
|
78
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
79
|
+
mockedFs.existsSync.mockImplementation((filePath) => {
|
|
80
|
+
return String(filePath).includes('.commitgenierc.json');
|
|
81
|
+
});
|
|
82
|
+
mockedFs.readFileSync.mockReturnValue(JSON.stringify({
|
|
83
|
+
defaultType: 'chore',
|
|
84
|
+
}));
|
|
85
|
+
const config = configService_1.ConfigService.loadConfig();
|
|
86
|
+
expect(config.defaultType).toBe('chore');
|
|
87
|
+
expect(config.maxMessageLength).toBe(72); // Default preserved
|
|
88
|
+
});
|
|
89
|
+
it('should cache config after first load', () => {
|
|
90
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
91
|
+
mockedFs.existsSync.mockReturnValue(false);
|
|
92
|
+
configService_1.ConfigService.loadConfig();
|
|
93
|
+
configService_1.ConfigService.loadConfig();
|
|
94
|
+
configService_1.ConfigService.loadConfig();
|
|
95
|
+
// getGitRoot should only be called once due to caching
|
|
96
|
+
expect(mockedGitService.getGitRoot).toHaveBeenCalledTimes(1);
|
|
97
|
+
});
|
|
98
|
+
it('should handle invalid JSON gracefully', () => {
|
|
99
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
100
|
+
mockedFs.existsSync.mockImplementation((filePath) => {
|
|
101
|
+
return String(filePath).includes('.commitgenierc.json');
|
|
102
|
+
});
|
|
103
|
+
mockedFs.readFileSync.mockReturnValue('{ invalid json }');
|
|
104
|
+
// Should not throw, should return defaults
|
|
105
|
+
const config = configService_1.ConfigService.loadConfig();
|
|
106
|
+
expect(config.defaultType).toBe('feat');
|
|
107
|
+
});
|
|
108
|
+
it('should fallback to cwd when not in git repo', () => {
|
|
109
|
+
mockedGitService.getGitRoot.mockImplementation(() => {
|
|
110
|
+
throw new Error('Not a git repo');
|
|
111
|
+
});
|
|
112
|
+
mockedFs.existsSync.mockReturnValue(false);
|
|
113
|
+
const config = configService_1.ConfigService.loadConfig();
|
|
114
|
+
expect(config).toBeDefined();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe('getConfig', () => {
|
|
118
|
+
it('should return loaded config', () => {
|
|
119
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
120
|
+
mockedFs.existsSync.mockReturnValue(false);
|
|
121
|
+
const config = configService_1.ConfigService.getConfig();
|
|
122
|
+
expect(config).toBeDefined();
|
|
123
|
+
expect(config.defaultType).toBe('feat');
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('clearCache', () => {
|
|
127
|
+
it('should clear the cached config', () => {
|
|
128
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
129
|
+
mockedFs.existsSync.mockReturnValue(false);
|
|
130
|
+
configService_1.ConfigService.loadConfig();
|
|
131
|
+
configService_1.ConfigService.clearCache();
|
|
132
|
+
configService_1.ConfigService.loadConfig();
|
|
133
|
+
expect(mockedGitService.getGitRoot).toHaveBeenCalledTimes(2);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe('initConfig', () => {
|
|
137
|
+
it('should create config file successfully', () => {
|
|
138
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
139
|
+
mockedFs.existsSync.mockReturnValue(false);
|
|
140
|
+
mockedFs.writeFileSync.mockImplementation(() => { });
|
|
141
|
+
const result = configService_1.ConfigService.initConfig();
|
|
142
|
+
expect(result.success).toBe(true);
|
|
143
|
+
expect(result.message).toBe('Config file created');
|
|
144
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalled();
|
|
145
|
+
});
|
|
146
|
+
it('should fail if config already exists', () => {
|
|
147
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
148
|
+
mockedFs.existsSync.mockReturnValue(true);
|
|
149
|
+
const result = configService_1.ConfigService.initConfig();
|
|
150
|
+
expect(result.success).toBe(false);
|
|
151
|
+
expect(result.message).toBe('Config file already exists');
|
|
152
|
+
});
|
|
153
|
+
it('should handle write errors', () => {
|
|
154
|
+
mockedGitService.getGitRoot.mockReturnValue('/project');
|
|
155
|
+
mockedFs.existsSync.mockReturnValue(false);
|
|
156
|
+
mockedFs.writeFileSync.mockImplementation(() => {
|
|
157
|
+
throw new Error('Permission denied');
|
|
158
|
+
});
|
|
159
|
+
const result = configService_1.ConfigService.initConfig();
|
|
160
|
+
expect(result.success).toBe(false);
|
|
161
|
+
expect(result.message).toContain('Failed to create config');
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
//# sourceMappingURL=configService.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configService.test.js","sourceRoot":"","sources":["../../src/services/configService.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,mDAAgD;AAChD,6CAA0C;AAE1C,oBAAoB;AACpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAE1B,MAAM,QAAQ,GAAG,EAA4B,CAAC;AAC9C,MAAM,gBAAgB,GAAG,uBAA4C,CAAC;AAEtE,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,6BAAa,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;YACjE,gBAAgB,CAAC,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACxD,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAE3C,MAAM,MAAM,GAAG,6BAAa,CAAC,UAAU,EAAE,CAAC;YAE1C,MAA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|
4
|
+
* Check if current directory is a git repository
|
|
5
|
+
*/
|
|
6
|
+
static isGitRepository(): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Get current git status with staged and unstaged files
|
|
9
|
+
*/
|
|
10
|
+
static getStatus(): GitStatus;
|
|
11
|
+
/**
|
|
12
|
+
* Get diff statistics for staged changes
|
|
13
|
+
*/
|
|
14
|
+
static getDiffStats(): DiffStats;
|
|
15
|
+
/**
|
|
16
|
+
* Get the actual diff content for staged changes
|
|
17
|
+
*/
|
|
18
|
+
static getDiff(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get list of staged files with their status
|
|
21
|
+
*/
|
|
22
|
+
static getStagedFiles(): FileChange[];
|
|
23
|
+
/**
|
|
24
|
+
* Commit staged changes with the given message (supports multi-line)
|
|
25
|
+
*/
|
|
26
|
+
static commit(message: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Amend the last commit with a new message
|
|
29
|
+
*/
|
|
30
|
+
static amendCommit(message: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get the last commit's message
|
|
33
|
+
*/
|
|
34
|
+
static getLastCommitMessage(): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Get files changed in the last commit
|
|
37
|
+
*/
|
|
38
|
+
static getLastCommitFiles(): FileChange[];
|
|
39
|
+
/**
|
|
40
|
+
* Get diff of the last commit
|
|
41
|
+
*/
|
|
42
|
+
static getLastCommitDiff(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Check if there are any commits in the repository
|
|
45
|
+
*/
|
|
46
|
+
static hasCommits(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get the root directory of the git repository
|
|
49
|
+
*/
|
|
50
|
+
static getGitRoot(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Get the .git directory path (works reliably on Windows)
|
|
53
|
+
*/
|
|
54
|
+
static getGitDir(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Get the current branch name
|
|
57
|
+
*/
|
|
58
|
+
static getCurrentBranch(): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Get recent commit history
|
|
61
|
+
*/
|
|
62
|
+
static getCommitHistory(count?: number): HistoricalCommit[];
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=gitService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitService.d.ts","sourceRoot":"","sources":["../../src/services/gitService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE9E,qBAAa,UAAU;IACrB;;OAEG;IACH,MAAM,CAAC,eAAe,IAAI,OAAO;IASjC;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,SAAS;IAuC7B;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,SAAS;IA0BhC;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,MAAM;IAYxB;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,UAAU,EAAE;IAKrC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAqBpC;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAoBzC;;OAEG;IACH,MAAM,CAAC,oBAAoB,IAAI,MAAM,GAAG,IAAI;IAW5C;;OAEG;IACH,MAAM,CAAC,kBAAkB,IAAI,UAAU,EAAE;IAwBzC;;OAEG;IACH,MAAM,CAAC,iBAAiB,IAAI,MAAM;IAWlC;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,OAAO;IAS5B;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM;IAW3B;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,MAAM;IAqB1B;;OAEG;IACH,MAAM,CAAC,gBAAgB,IAAI,MAAM,GAAG,IAAI;IAYxC;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,GAAE,MAAW,GAAG,gBAAgB,EAAE;CAsChE"}
|