git-it-done 1.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 +2 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/checkGitStatus.d.ts +2 -0
- package/dist/utils/checkGitStatus.js +37 -0
- package/dist/utils/checkGitStatus.js.map +1 -0
- package/dist/utils/commitMessage.d.ts +2 -0
- package/dist/utils/commitMessage.js +87 -0
- package/dist/utils/commitMessage.js.map +1 -0
- package/dist/utils/displayStatus.d.ts +2 -0
- package/dist/utils/displayStatus.js +24 -0
- package/dist/utils/displayStatus.js.map +1 -0
- package/dist/utils/fileStaging.d.ts +2 -0
- package/dist/utils/fileStaging.js +98 -0
- package/dist/utils/fileStaging.js.map +1 -0
- package/dist/utils/formatFileStatus.d.ts +1 -0
- package/dist/utils/formatFileStatus.js +24 -0
- package/dist/utils/formatFileStatus.js.map +1 -0
- package/dist/utils/generateCommitMessage.d.ts +2 -0
- package/dist/utils/generateCommitMessage.js +111 -0
- package/dist/utils/generateCommitMessage.js.map +1 -0
- package/dist/utils/getFileChanges.d.ts +2 -0
- package/dist/utils/getFileChanges.js +28 -0
- package/dist/utils/getFileChanges.js.map +1 -0
- package/dist/utils/gitCommand.d.ts +1 -0
- package/dist/utils/gitCommand.js +17 -0
- package/dist/utils/gitCommand.js.map +1 -0
- package/dist/utils/isGitrepo.d.ts +1 -0
- package/dist/utils/isGitrepo.js +9 -0
- package/dist/utils/isGitrepo.js.map +1 -0
- package/dist/utils/performCommit.d.ts +1 -0
- package/dist/utils/performCommit.js +79 -0
- package/dist/utils/performCommit.js.map +1 -0
- package/dist/utils/process_interruption.d.ts +1 -0
- package/dist/utils/process_interruption.js +20 -0
- package/dist/utils/process_interruption.js.map +1 -0
- package/dist/utils/push_to_remote.d.ts +1 -0
- package/dist/utils/push_to_remote.js +68 -0
- package/dist/utils/push_to_remote.js.map +1 -0
- package/dist/utils/types/types.d.ts +19 -0
- package/dist/utils/types/types.js +3 -0
- package/dist/utils/types/types.js.map +1 -0
- package/package.json +28 -0
- package/readme.md +14 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const prompts_1 = require("@clack/prompts");
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const checkGitStatus_1 = require("./utils/checkGitStatus");
|
|
19
|
+
const getFileChanges_1 = require("./utils/getFileChanges");
|
|
20
|
+
const displayStatus_1 = require("./utils/displayStatus");
|
|
21
|
+
const fileStaging_1 = require("./utils/fileStaging");
|
|
22
|
+
const commitMessage_1 = require("./utils/commitMessage");
|
|
23
|
+
const performCommit_1 = require("./utils/performCommit");
|
|
24
|
+
const push_to_remote_1 = require("./utils/push_to_remote");
|
|
25
|
+
const process_interruption_1 = __importDefault(require("./utils/process_interruption"));
|
|
26
|
+
function main() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
console.clear();
|
|
29
|
+
(0, prompts_1.intro)(chalk_1.default.bgBlue(' Auto Commit Tool '));
|
|
30
|
+
// 1. Validate git repository and configuration
|
|
31
|
+
const gitStatus = (0, checkGitStatus_1.checkGitStatus)();
|
|
32
|
+
if (!gitStatus.valid) {
|
|
33
|
+
(0, prompts_1.cancel)(gitStatus.reason);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
// 2. Get current repository changes
|
|
37
|
+
const changes = (0, getFileChanges_1.getChanges)();
|
|
38
|
+
const allFiles = [...changes.staged, ...changes.unstaged, ...changes.untracked];
|
|
39
|
+
// 3. Handle no changes case
|
|
40
|
+
if (allFiles.length === 0) {
|
|
41
|
+
(0, prompts_1.outro)(chalk_1.default.green('⨠Working directory is clean. Nothing to commit! đ'));
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
// 4. Display current repository status
|
|
45
|
+
(0, displayStatus_1.displayRepositoryStatus)(changes);
|
|
46
|
+
// 5. Handle file staging if needed
|
|
47
|
+
const filesToCommit = yield (0, fileStaging_1.handleFileStaging)(changes);
|
|
48
|
+
if (filesToCommit.length === 0) {
|
|
49
|
+
(0, prompts_1.outro)(chalk_1.default.yellow('âšī¸ No files to commit after staging process.'));
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
// 6. Handle commit message creation
|
|
53
|
+
const commitMessage = yield (0, commitMessage_1.handleCommitMessage)(filesToCommit);
|
|
54
|
+
// 7. Perform the commit
|
|
55
|
+
const commitSuccess = yield (0, performCommit_1.performCommit)(commitMessage);
|
|
56
|
+
if (!commitSuccess) {
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
// 8. Handle push to remote
|
|
60
|
+
yield (0, push_to_remote_1.handlePushToRemote)();
|
|
61
|
+
(0, prompts_1.outro)(chalk_1.default.green('đ All done!'));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
(0, process_interruption_1.default)(main);
|
|
65
|
+
//# sourceM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AC/B,IAAA,eAAK,EAAC,eAAK,CAAC,MAAM,CAAC,+CAA+C,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,oCAAoC;QACpC,MAAM,aAAa,GAAG,MAAM,IAAA,mCAAmB,EAAC,aAAa,CAAC,CAAC;QAE/D,wBAAwB;QACxB,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAa,EAAC,aAAa,CAAC,CAAC;QAEzD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,2BAA2B;QAC3B,MAAM,IAAA,mCAAkB,GAAE,CAAC;QAE3B,IAAA,eAAK,EAAC,eAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IACrC,CAAC;CAAA;AAED,IAAA,8BAAK,EAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkGitStatus = checkGitStatus;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const gitCommand_1 = require("./gitCommand");
|
|
6
|
+
// Enhanced function to check git repository status
|
|
7
|
+
function checkGitStatus() {
|
|
8
|
+
// Step 1: Check if Git is installed
|
|
9
|
+
try {
|
|
10
|
+
(0, child_process_1.execSync)('git --version', { stdio: 'ignore' });
|
|
11
|
+
}
|
|
12
|
+
catch (_a) {
|
|
13
|
+
return {
|
|
14
|
+
valid: false,
|
|
15
|
+
reason: 'Git is not installed or not in PATH',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// Step 2: Check if inside a Git repository
|
|
19
|
+
if (!(0, gitCommand_1.gitCommand)('rev-parse --git-dir')) {
|
|
20
|
+
return {
|
|
21
|
+
valid: false,
|
|
22
|
+
reason: 'Not in a Git repository',
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Step 3: Check if Git user config is set
|
|
26
|
+
const userName = (0, gitCommand_1.gitCommand)('config user.name');
|
|
27
|
+
const userEmail = (0, gitCommand_1.gitCommand)('config user.email');
|
|
28
|
+
if (!userName || !userEmail) {
|
|
29
|
+
return {
|
|
30
|
+
valid: false,
|
|
31
|
+
reason: `Git user not configured. Run:\n git config --global user.name "Your Name"\n git config --global user.email "you@example.com"`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// All checks passed
|
|
35
|
+
return { valid: true };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=checkGitStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkGitStatus.js","sourceRoot":"","sources":["../../src/utils/checkGitStatus.ts"],"names":[],"mappings":";;AAKA,wCAgCC;AArCD,iDAAyC;AACzC,6CAA0C;AAG1C,mDAAmD;AACnD,SAAgB,cAAc;IAC5B,oCAAoC;IACpC,IAAI,CAAC;QACH,IAAA,wBAAQ,EAAC,eAAe,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,WAAM,CAAC;QACP,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,qCAAqC;SAC9C,CAAC;IACJ,CAAC;IAED,2CAA2C;IAC3C,IAAI,CAAC,IAAA,uBAAU,EAAC,qBAAqB,CAAC,EAAE,CAAC;QACvC,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,yBAAyB;SAClC,CAAC;IACJ,CAAC;IAED,0CAA0C;IAC1C,MAAM,QAAQ,GAAG,IAAA,uBAAU,EAAC,kBAAkB,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,IAAA,uBAAU,EAAC,mBAAmB,CAAC,CAAC;IAElD,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,gIAAgI;SACzI,CAAC;IACJ,CAAC;IAED,oBAAoB;IACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.handleCommitMessage = handleCommitMessage;
|
|
16
|
+
const prompts_1 = require("@clack/prompts");
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const generateCommitMessage_1 = require("./generateCommitMessage");
|
|
19
|
+
const formatFileStatus_1 = require("./formatFileStatus");
|
|
20
|
+
function handleCommitMessage(filesToCommit) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
// Display files to commit
|
|
23
|
+
displayFilesToCommit(filesToCommit);
|
|
24
|
+
// Generate automatic commit message
|
|
25
|
+
const generatedMessage = (0, generateCommitMessage_1.generateCommitMessage)(filesToCommit);
|
|
26
|
+
// Get user preference for commit message
|
|
27
|
+
const messageOption = yield getMessageOption(generatedMessage);
|
|
28
|
+
if ((0, prompts_1.isCancel)(messageOption)) {
|
|
29
|
+
(0, prompts_1.cancel)('Operation cancelled');
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
// Handle different message options
|
|
33
|
+
let commitMessage = generatedMessage;
|
|
34
|
+
if (messageOption === 'custom') {
|
|
35
|
+
commitMessage = yield getCustomMessage();
|
|
36
|
+
}
|
|
37
|
+
else if (messageOption === 'edit') {
|
|
38
|
+
commitMessage = yield getEditedMessage(generatedMessage);
|
|
39
|
+
}
|
|
40
|
+
return commitMessage;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function displayFilesToCommit(filesToCommit) {
|
|
44
|
+
console.log(chalk_1.default.bold('\nđ Files to commit:'));
|
|
45
|
+
filesToCommit.forEach(({ status, file }) => console.log(` ${(0, formatFileStatus_1.formatFileStatus)(status)} ${file}`));
|
|
46
|
+
}
|
|
47
|
+
function getMessageOption(generatedMessage) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return yield (0, prompts_1.select)({
|
|
50
|
+
message: 'How would you like to create the commit message?',
|
|
51
|
+
options: [
|
|
52
|
+
{ value: 'generated', label: `Use generated: "${generatedMessage}"` },
|
|
53
|
+
{ value: 'custom', label: 'Write custom message' },
|
|
54
|
+
{ value: 'edit', label: 'Edit generated message' }
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function getCustomMessage() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const commitMessage = yield (0, prompts_1.text)({
|
|
62
|
+
message: 'Enter commit message:',
|
|
63
|
+
placeholder: 'feat: add new feature',
|
|
64
|
+
validate: value => !value.trim() ? 'Commit message is required' : undefined
|
|
65
|
+
});
|
|
66
|
+
if ((0, prompts_1.isCancel)(commitMessage)) {
|
|
67
|
+
(0, prompts_1.cancel)('Operation cancelled');
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
return commitMessage;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function getEditedMessage(generatedMessage) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const commitMessage = yield (0, prompts_1.text)({
|
|
76
|
+
message: 'Edit commit message:',
|
|
77
|
+
initialValue: generatedMessage,
|
|
78
|
+
validate: value => !value.trim() ? 'Commit message is required' : undefined
|
|
79
|
+
});
|
|
80
|
+
if ((0, prompts_1.isCancel)(commitMessage)) {
|
|
81
|
+
(0, prompts_1.cancel)('Operation cancelled');
|
|
82
|
+
process.exit(0);
|
|
83
|
+
}
|
|
84
|
+
return commitMessage;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=commitMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitMessage.js","sourceRoot":"","sources":["../../src/utils/commitMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,kDAyBC;AA/BD,4CAAgE;AAChE,kDAA0B;AAC1B,mEAAgE;AAChE,yDAAsD;AAGtD,SAAsB,mBAAmB,CAAC,aAA2B;;QACnE,0BAA0B;QAC1B,oBAAoB,CAAC,aAAa,CAAC,CAAC;QAEpC,oCAAoC;QACpC,MAAM,gBAAgB,GAAG,IAAA,6CAAqB,EAAC,aAAa,CAAC,CAAC;QAE9D,yCAAyC;QACzC,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAE/D,IAAI,IAAA,kBAAQ,EAAC,aAAa,CAAC,EAAE,CAAC;YAC5B,IAAA,gBAAM,EAAC,qBAAqB,CAAC,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,mCAAmC;QACnC,IAAI,aAAa,GAAG,gBAAgB,CAAC;QAErC,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;YAC/B,aAAa,GAAG,MAAM,gBAAgB,EAAE,CAAC;QAC3C,CAAC;aAAM,IAAI,aAAa,KAAK,MAAM,EAAE,C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aAAa,CAAC;IACvB,CAAC;CAAA;AAED,SAAe,gBAAgB,CAAC,gBAAwB;;QACtD,MAAM,aAAa,GAAG,MAAM,IAAA,cAAI,EAAC;YAC/B,OAAO,EAAE,sBAAsB;YAC/B,YAAY,EAAE,gBAAgB;YAC9B,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,SAAS;SAC5E,CAAW,CAAC;QAEb,IAAI,IAAA,kBAAQ,EAAC,aAAa,CAAC,EAAE,CAAC;YAC5B,IAAA,gBAAM,EAAC,qBAAqB,CAAC,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.displayRepositoryStatus = displayRepositoryStatus;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const formatFileStatus_1 = require("./formatFileStatus");
|
|
9
|
+
function displayRepositoryStatus(changes) {
|
|
10
|
+
console.log(chalk_1.default.bold('\nđ Repository Status:'));
|
|
11
|
+
if (changes.staged.length > 0) {
|
|
12
|
+
console.log(chalk_1.default.green('\nStaged files:'));
|
|
13
|
+
changes.staged.forEach(({ status, file }) => console.log(` ${(0, formatFileStatus_1.formatFileStatus)(status)} ${file}`));
|
|
14
|
+
}
|
|
15
|
+
if (changes.unstaged.length > 0) {
|
|
16
|
+
console.log(chalk_1.default.yellow('\nUnstaged files:'));
|
|
17
|
+
changes.unstaged.forEach(({ status, file }) => console.log(` ${(0, formatFileStatus_1.formatFileStatus)(status)} ${file}`));
|
|
18
|
+
}
|
|
19
|
+
if (changes.untracked.length > 0) {
|
|
20
|
+
console.log(chalk_1.default.cyan('\nUntracked files:'));
|
|
21
|
+
changes.untracked.forEach(({ status, file }) => console.log(` ${(0, formatFileStatus_1.formatFileStatus)(status)} ${file}`));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=displayStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"displayStatus.js","sourceRoot":"","sources":["../../src/utils/displayStatus.ts"],"names":[],"mappings":";;;;;AAIA,0DAuBC;AA3BD,kDAA0B;AAE1B,yDAAsD;AAEtD,SAAgB,uBAAuB,CAAC,OAAmB;IACzD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAEnD,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAC5C,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAC1C,OAAO,CAAC,GAAG,CAAC,KAAK,IAAA,mCAAgB,EAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CACrD,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAC5C,OAAO,CAAC,GAAG,CAAC,KAAK,IAAA,mCAAgB,EAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CACrD,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAC7C,OAAO,CAAC,GAAG,CAAC,KAAK,IAAA,mCAAgB,EAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CACrD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.handleFileStaging = handleFileStaging;
|
|
16
|
+
const prompts_1 = require("@clack/prompts");
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const gitCommand_1 = require("./gitCommand");
|
|
19
|
+
const getFileChanges_1 = require("./getFileChanges");
|
|
20
|
+
const formatFileStatus_1 = require("./formatFileStatus");
|
|
21
|
+
function handleFileStaging(changes) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
let filesToCommit = changes.staged;
|
|
24
|
+
// If files are already staged, return them
|
|
25
|
+
if (changes.staged.length > 0) {
|
|
26
|
+
return filesToCommit;
|
|
27
|
+
}
|
|
28
|
+
// Handle unstaged files
|
|
29
|
+
const stageOption = yield (0, prompts_1.select)({
|
|
30
|
+
message: 'No files are staged. What would you like to do?',
|
|
31
|
+
options: [
|
|
32
|
+
{ value: 'all', label: 'Stage all changes' },
|
|
33
|
+
{ value: 'select', label: 'Select files to stage' },
|
|
34
|
+
{ value: 'cancel', label: 'Cancel' }
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
if ((0, prompts_1.isCancel)(stageOption) || stageOption === 'cancel') {
|
|
38
|
+
(0, prompts_1.cancel)('Operation cancelled');
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
if (stageOption === 'all') {
|
|
42
|
+
filesToCommit = yield stageAllFiles();
|
|
43
|
+
}
|
|
44
|
+
else if (stageOption === 'select') {
|
|
45
|
+
filesToCommit = yield stageSelectedFiles(changes);
|
|
46
|
+
}
|
|
47
|
+
return filesToCommit;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function stageAllFiles() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const s = (0, prompts_1.spinner)();
|
|
53
|
+
s.start('Staging all files...');
|
|
54
|
+
const result = (0, gitCommand_1.gitCommand)('add .');
|
|
55
|
+
if (result === null) {
|
|
56
|
+
s.stop('â Failed to stage files');
|
|
57
|
+
(0, prompts_1.cancel)('Failed to stage files');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
s.stop('All files staged');
|
|
61
|
+
return (0, getFileChanges_1.getChanges)().staged;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function stageSelectedFiles(changes) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const unstaged = [...changes.unstaged, ...changes.untracked];
|
|
67
|
+
const selectedFiles = yield (0, prompts_1.multiselect)({
|
|
68
|
+
message: 'Select files to stage:',
|
|
69
|
+
options: unstaged.map(({ status, file }) => ({
|
|
70
|
+
value: file,
|
|
71
|
+
label: `${(0, formatFileStatus_1.formatFileStatus)(status)} ${file}`
|
|
72
|
+
})),
|
|
73
|
+
required: true
|
|
74
|
+
});
|
|
75
|
+
if ((0, prompts_1.isCancel)(selectedFiles)) {
|
|
76
|
+
(0, prompts_1.cancel)('Operation cancelled');
|
|
77
|
+
process.exit(0);
|
|
78
|
+
}
|
|
79
|
+
const s = (0, prompts_1.spinner)();
|
|
80
|
+
s.start('Staging selected files...');
|
|
81
|
+
let stagingFailed = false;
|
|
82
|
+
selectedFiles.forEach(file => {
|
|
83
|
+
const result = (0, gitCommand_1.gitCommand)(`add "${file}"`);
|
|
84
|
+
if (result === null) {
|
|
85
|
+
stagingFailed = true;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (stagingFailed) {
|
|
89
|
+
s.stop('â Some files failed to stage');
|
|
90
|
+
console.log(chalk_1.default.yellow('Some files may not have been staged properly.'));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
s.stop('Files staged');
|
|
94
|
+
}
|
|
95
|
+
return (0, getFileChanges_1.getChanges)().staged;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=fileStaging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileStaging.js","sourceRoot":"","sources":["../../src/utils/fileStaging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,8CA8BC;AArCD,4CAAgF;AAChF,kDAA0B;AAC1B,6CAA0C;AAC1C,qDAA8C;AAC9C,yDAAsD;AAGtD,SAAsB,iBAAiB,CAAC,OAAmB;;QACzD,IAAI,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;QAEnC,2CAA2C;QAC3C,IAAI,OAAO,CAAC,MAAM,CAAC,M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CAAC,+CAA+C,CAAC,CAAC,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACzB,CAAC;QAED,OAAO,IAAA,2BAAU,GAAE,CAAC,MAAM,CAAC;IAC7B,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatFileStatus(status: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatFileStatus = formatFileStatus;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
function formatFileStatus(status) {
|
|
9
|
+
switch (status) {
|
|
10
|
+
case 'A':
|
|
11
|
+
return chalk_1.default.green('+ added');
|
|
12
|
+
case 'M':
|
|
13
|
+
return chalk_1.default.yellow('~ modified');
|
|
14
|
+
case 'D':
|
|
15
|
+
return chalk_1.default.red('- deleted');
|
|
16
|
+
case 'R':
|
|
17
|
+
return chalk_1.default.blue('â renamed');
|
|
18
|
+
case '??':
|
|
19
|
+
return chalk_1.default.cyan('? untracked');
|
|
20
|
+
default:
|
|
21
|
+
return chalk_1.default.gray(status);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=formatFileStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatFileStatus.js","sourceRoot":"","sources":["../../src/utils/formatFileStatus.ts"],"names":[],"mappings":";;;;;AAEA,4CAeC;AAjBD,kDAA0B;AAE1B,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,eAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACpC,KAAK,GAAG;YACN,OAAO,eAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjC,KAAK,IAAI;YACP,OAAO,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnC;YACE,OAAO,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateCommitMessage = generateCommitMessage;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const gitCommand_1 = require("./gitCommand");
|
|
9
|
+
// Generate commit message based on changes
|
|
10
|
+
function generateCommitMessage(files) {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const fileTypes = new Map();
|
|
13
|
+
const operations = { added: 0, modified: 0, deleted: 0, renamed: 0 };
|
|
14
|
+
let scope = '';
|
|
15
|
+
// Analyze files
|
|
16
|
+
for (const { status, file } of files) {
|
|
17
|
+
const ext = path_1.default.extname(file);
|
|
18
|
+
fileTypes.set(ext, (fileTypes.get(ext) || 0) + 1);
|
|
19
|
+
switch (status) {
|
|
20
|
+
case 'A':
|
|
21
|
+
operations.added++;
|
|
22
|
+
break;
|
|
23
|
+
case 'M':
|
|
24
|
+
operations.modified++;
|
|
25
|
+
break;
|
|
26
|
+
case 'D':
|
|
27
|
+
operations.deleted++;
|
|
28
|
+
break;
|
|
29
|
+
case 'R':
|
|
30
|
+
operations.renamed++;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
// Determine scope from top-level directory
|
|
34
|
+
if (!scope) {
|
|
35
|
+
const dir = file.split('/')[0];
|
|
36
|
+
if (dir && dir !== file) {
|
|
37
|
+
scope = dir;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Detect content types
|
|
42
|
+
const hasPattern = (regex) => files.some(f => regex.test(f.file));
|
|
43
|
+
const hasTests = hasPattern(/test|spec/i);
|
|
44
|
+
const hasDocs = hasPattern(/readme|doc|\.md$/i);
|
|
45
|
+
const hasConfig = hasPattern(/config|\.json$|\.ya?ml$|package\.json/i);
|
|
46
|
+
const hasStyles = hasPattern(/\.(css|scss|sass|less)$/i);
|
|
47
|
+
const hasDeps = hasPattern(/package(-lock)?\.json|yarn\.lock|requirements\.txt/i);
|
|
48
|
+
// Determine type and description
|
|
49
|
+
let type = 'chore';
|
|
50
|
+
let description = '';
|
|
51
|
+
if (hasDeps) {
|
|
52
|
+
type = 'deps';
|
|
53
|
+
description = 'update dependencies';
|
|
54
|
+
}
|
|
55
|
+
else if (hasTests) {
|
|
56
|
+
type = 'test';
|
|
57
|
+
description = 'update tests';
|
|
58
|
+
}
|
|
59
|
+
else if (hasDocs) {
|
|
60
|
+
type = 'docs';
|
|
61
|
+
description = 'update documentation';
|
|
62
|
+
}
|
|
63
|
+
else if (hasConfig) {
|
|
64
|
+
type = 'config';
|
|
65
|
+
description = 'update configuration';
|
|
66
|
+
}
|
|
67
|
+
else if (hasStyles) {
|
|
68
|
+
type = 'style';
|
|
69
|
+
description = 'update styles';
|
|
70
|
+
}
|
|
71
|
+
else if (operations.added > 0 && operations.modified === 0 && operations.deleted === 0) {
|
|
72
|
+
type = 'feat';
|
|
73
|
+
description = operations.added === 1
|
|
74
|
+
? `add ${path_1.default.basename(((_a = files.find(f => f.status === 'A')) === null || _a === void 0 ? void 0 : _a.file) || '')}`
|
|
75
|
+
: 'add new files';
|
|
76
|
+
}
|
|
77
|
+
else if (operations.deleted > 0 && operations.added === 0 && operations.modified === 0) {
|
|
78
|
+
type = 'remove';
|
|
79
|
+
description = operations.deleted === 1
|
|
80
|
+
? `remove ${path_1.default.basename(((_b = files.find(f => f.status === 'D')) === null || _b === void 0 ? void 0 : _b.file) || '')}`
|
|
81
|
+
: 'remove files';
|
|
82
|
+
}
|
|
83
|
+
else if (operations.modified > 0) {
|
|
84
|
+
type = 'fix';
|
|
85
|
+
description = operations.modified === 1 && operations.added === 0 && operations.deleted === 0
|
|
86
|
+
? `update ${path_1.default.basename(((_c = files.find(f => f.status === 'M')) === null || _c === void 0 ? void 0 : _c.file) || '')}`
|
|
87
|
+
: 'update and improve code';
|
|
88
|
+
}
|
|
89
|
+
// Refine with diff content
|
|
90
|
+
try {
|
|
91
|
+
const diff = (0, gitCommand_1.gitCommand)('diff --cached') || '';
|
|
92
|
+
if (/bug|fix|error|issue/i.test(diff)) {
|
|
93
|
+
type = 'fix';
|
|
94
|
+
description = 'resolve issues and bugs';
|
|
95
|
+
}
|
|
96
|
+
else if (/refactor|restructure/i.test(diff)) {
|
|
97
|
+
type = 'refactor';
|
|
98
|
+
description = 'refactor code structure';
|
|
99
|
+
}
|
|
100
|
+
else if (/function|def|class|interface/i.test(diff) && type === 'fix') {
|
|
101
|
+
type = 'feat';
|
|
102
|
+
description = 'implement new functionality';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (_d) {
|
|
106
|
+
// Ignore diff errors
|
|
107
|
+
}
|
|
108
|
+
const scopeStr = scope ? `(${scope})` : '';
|
|
109
|
+
return `${type}${scopeStr}: ${description}`;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=generateCommitMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCommitMessage.js","sourceRoot":"","sources":["../../src/utils/generateCommitMessage.ts"],"names":[],"mappings":";;;;;AAKA,sDA2FC;AAhGD,gDAAwB;AACxB,6CAA0C;AAG1C,2CAA2C;AAC3C,SAAgB,qBAAqB,CAAC,KAAmB;;IACv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C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,IAAI,GAAG,UAAU,CAAC;YAClB,WAAW,GAAG,yBAAyB,CAAC;QAC1C,CAAC;aAAM,IAAI,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACxE,IAAI,GAAG,MAAM,CAAC;YACd,WAAW,GAAG,6BAA6B,CAAC;QAC9C,CAAC;IACH,CAAC;IAAC,WAAM,CAAC;QACP,qBAAqB;IACvB,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,OAAO,GAAG,IAAI,GAAG,QAAQ,KAAK,WAAW,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChanges = getChanges;
|
|
4
|
+
const gitCommand_1 = require("./gitCommand");
|
|
5
|
+
// Get file changes
|
|
6
|
+
function parseGitStatus(output, defaultStatus = '') {
|
|
7
|
+
return output
|
|
8
|
+
.split('\n')
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.map(line => {
|
|
11
|
+
if (defaultStatus) {
|
|
12
|
+
return { status: defaultStatus, file: line };
|
|
13
|
+
}
|
|
14
|
+
const [status, ...fileParts] = line.split('\t');
|
|
15
|
+
return { status, file: fileParts.join('\t') };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function getChanges() {
|
|
19
|
+
const stagedOutput = (0, gitCommand_1.gitCommand)('diff --cached --name-status') || '';
|
|
20
|
+
const unstagedOutput = (0, gitCommand_1.gitCommand)('diff --name-status') || '';
|
|
21
|
+
const untrackedOutput = (0, gitCommand_1.gitCommand)('ls-files --others --exclude-standard') || '';
|
|
22
|
+
return {
|
|
23
|
+
staged: parseGitStatus(stagedOutput),
|
|
24
|
+
unstaged: parseGitStatus(unstagedOutput),
|
|
25
|
+
untracked: parseGitStatus(untrackedOutput, '??')
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=getFileChanges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileChanges.js","sourceRoot":"","sources":["../../src/utils/getFileChanges.ts"],"names":[],"mappings":";;AAiBA,gCAUC;AA3BD,6CAA0C;AAG1C,mBAAmB;AACnB,SAAS,cAAc,CAAC,MAAc,EAAE,aAAa,GAAG,EAAE;IACxD,OAAO,MAAM;SACV,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,IAAI,CAAC,EAAE;QACV,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC/C,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAgB,UAAU;IACxB,MAAM,YAAY,GAAG,IAAA,uBAAU,EAAC,6BAA6B,CAAC,IAAI,EAAE,CAAC;IACrE,MAAM,cAAc,GAAG,IAAA,uBAAU,EAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC;IAC9D,MAAM,eAAe,GAAG,IAAA,uBAAU,EAAC,sCAAsC,CAAC,IAAI,EAAE,CAAC;IAEjF,OAAO;QACL,MAAM,EAAE,cAAc,CAAC,YAAY,CAAC;QACpC,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC;QACxC,SAAS,EAAE,cAAc,CAAC,eAAe,EAAE,IAAI,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function gitCommand(command: string): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gitCommand = gitCommand;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
// Utility function to execute git commands with better error handling
|
|
6
|
+
function gitCommand(command) {
|
|
7
|
+
try {
|
|
8
|
+
return (0, child_process_1.execSync)(`git ${command}`, {
|
|
9
|
+
encoding: 'utf-8',
|
|
10
|
+
stdio: 'pipe'
|
|
11
|
+
}).trim();
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=gitCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitCommand.js","sourceRoot":"","sources":["../../src/utils/gitCommand.ts"],"names":[],"mappings":";;AAGA,gCASC;AAZD,iDAAyC;AAEzC,sEAAsE;AACtE,SAAgB,UAAU,CAAC,OAAe;IACxC,IAAI,CAAC;QACH,OAAO,IAAA,wBAAQ,EAAC,OAAO,OAAO,EAAE,EAAE;YAChC,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;SACd,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isGitRepo(): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isGitRepo = isGitRepo;
|
|
4
|
+
const gitCommand_1 = require("./gitCommand");
|
|
5
|
+
// Check if we're in a git repository
|
|
6
|
+
function isGitRepo() {
|
|
7
|
+
return !!(0, gitCommand_1.gitCommand)('rev-parse --git-dir');
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=isGitrepo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isGitrepo.js","sourceRoot":"","sources":["../../src/utils/isGitrepo.ts"],"names":[],"mappings":";;AAGA,8BAEC;AALD,6CAA0C;AAE1C,qCAAqC;AACrC,SAAgB,SAAS;IACvB,OAAO,CAAC,CAAC,IAAA,uBAAU,EAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function performCommit(commitMessage: string): Promise<boolean>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.performCommit = performCommit;
|
|
16
|
+
const prompts_1 = require("@clack/prompts");
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const gitCommand_1 = require("./gitCommand");
|
|
19
|
+
function performCommit(commitMessage) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
// Confirm commit
|
|
22
|
+
const shouldCommit = yield (0, prompts_1.confirm)({
|
|
23
|
+
message: `Commit with message: "${commitMessage}"?`
|
|
24
|
+
});
|
|
25
|
+
if ((0, prompts_1.isCancel)(shouldCommit) || !shouldCommit) {
|
|
26
|
+
(0, prompts_1.cancel)('Commit cancelled');
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// Execute commit
|
|
30
|
+
const s = (0, prompts_1.spinner)();
|
|
31
|
+
s.start('Committing changes...');
|
|
32
|
+
try {
|
|
33
|
+
const success = executeCommit(commitMessage);
|
|
34
|
+
if (!success) {
|
|
35
|
+
s.stop('â Commit failed');
|
|
36
|
+
(0, prompts_1.cancel)('Failed to commit changes. Please check your git status.');
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// Verify commit was created
|
|
40
|
+
const lastCommit = (0, gitCommand_1.gitCommand)('log -1 --oneline');
|
|
41
|
+
if (!lastCommit) {
|
|
42
|
+
s.stop('â ī¸ Commit status unclear');
|
|
43
|
+
console.log(chalk_1.default.yellow('Commit may not have been created. Please check git status manually.'));
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
s.stop('â
Changes committed successfully!');
|
|
48
|
+
console.log(chalk_1.default.dim(`Last commit: ${lastCommit}`));
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
s.stop('â Commit failed');
|
|
54
|
+
handleCommitError(error);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function executeCommit(commitMessage) {
|
|
60
|
+
const escapedMessage = JSON.stringify(commitMessage);
|
|
61
|
+
const result = (0, gitCommand_1.gitCommand)(`commit -m ${escapedMessage}`);
|
|
62
|
+
return result !== null;
|
|
63
|
+
}
|
|
64
|
+
function handleCommitError(error) {
|
|
65
|
+
const msg = error.message || '';
|
|
66
|
+
if (msg.includes('nothing to commit')) {
|
|
67
|
+
(0, prompts_1.cancel)('Nothing to commit - working tree clean');
|
|
68
|
+
}
|
|
69
|
+
else if (msg.includes('Please tell me who you are')) {
|
|
70
|
+
(0, prompts_1.cancel)('Git user not configured. Run: git config --global user.email "you@example.com"');
|
|
71
|
+
}
|
|
72
|
+
else if (msg.includes('not a git repository')) {
|
|
73
|
+
(0, prompts_1.cancel)('Not in a git repository');
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
(0, prompts_1.cancel)(`Failed to commit: ${msg}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=performCommit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performCommit.js","sourceRoot":"","sources":["../../src/utils/performCommit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,sCAyCC;AA7CD,4CAAoE;AACpE,kDAA0B;AAC1B,6CAA0C;AAE1C,SAAsB,aAAa,CAAC,aAAqB;;QACvD,iBAAiB;QACjB,MAAM,YAAY,GAAG,MAAM,IAAA,iBAAO,EAAC;YACjC,OAAO,EAAE,yBAAyB,aAAa,IAAI;SACpD,CAAC,CAAC;QAEH,IAAI,IAAA,kBAAQ,EAAC,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5C,IAAA,gBAAM,EAAC,kBAAkB,CAAC,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,iBAAiB;QACjB,MAAM,CAAC,GAAG,IAAA,iBAAO,GAAE,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAEjC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;YAE7C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;gBAC1B,IAAA,gBAAM,EAAC,yDAAyD,CAAC,CAAC;gBAClE,OAAO,KAAK,CAAC;YACf,CAAC;YAED,4BAA4B;YAC5B,MAAM,UAAU,GAA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C,EAAE,CAAC;QAChD,IAAA,gBAAM,EAAC,yBAAyB,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,IAAA,gBAAM,EAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function start(main: () => Promise<void>): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = start;
|
|
4
|
+
const prompts_1 = require("@clack/prompts");
|
|
5
|
+
function start(main) {
|
|
6
|
+
process.on('SIGINT', () => {
|
|
7
|
+
(0, prompts_1.cancel)('Operation cancelled by user');
|
|
8
|
+
process.exit(0);
|
|
9
|
+
});
|
|
10
|
+
process.on('SIGTERM', () => {
|
|
11
|
+
(0, prompts_1.cancel)('Operation terminated');
|
|
12
|
+
process.exit(0);
|
|
13
|
+
});
|
|
14
|
+
main().catch((error) => {
|
|
15
|
+
(0, prompts_1.cancel)('An unexpected error occurred');
|
|
16
|
+
console.error(error instanceof Error ? error.stack || error.message : error);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=process_interruption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process_interruption.js","sourceRoot":"","sources":["../../src/utils/process_interruption.ts"],"names":[],"mappings":";;AAEA,wBAgBC;AAlBD,4CAAwC;AAExC,SAAwB,KAAK,CAAC,IAAyB;IACrD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,IAAA,gBAAM,EAAC,6BAA6B,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACzB,IAAA,gBAAM,EAAC,sBAAsB,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC9B,IAAA,gBAAM,EAAC,8BAA8B,CAAC,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function handlePushToRemote(): Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.handlePushToRemote = handlePushToRemote;
|
|
16
|
+
const prompts_1 = require("@clack/prompts");
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const gitCommand_1 = require("./gitCommand");
|
|
19
|
+
function handlePushToRemote() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const shouldPush = yield (0, prompts_1.confirm)({
|
|
22
|
+
message: 'Push to remote repository?'
|
|
23
|
+
});
|
|
24
|
+
if ((0, prompts_1.isCancel)(shouldPush) || !shouldPush) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
yield executePush();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function executePush() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const pushSpinner = (0, prompts_1.spinner)();
|
|
33
|
+
pushSpinner.start('Pushing to remote...');
|
|
34
|
+
// Check if remote exists
|
|
35
|
+
const remotes = (0, gitCommand_1.gitCommand)('remote');
|
|
36
|
+
if (!remotes) {
|
|
37
|
+
pushSpinner.stop('â ī¸ No remote repository configured');
|
|
38
|
+
console.log(chalk_1.default.yellow('No remote repository found. Skipping push.'));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const pushResult = (0, gitCommand_1.gitCommand)('push');
|
|
43
|
+
if (pushResult !== null) {
|
|
44
|
+
pushSpinner.stop('đ Changes pushed successfully!');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
pushSpinner.stop('â Push failed');
|
|
48
|
+
handlePushFailure();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
pushSpinner.stop('â Push failed');
|
|
53
|
+
console.log(chalk_1.default.red('Failed to push. Error details:'));
|
|
54
|
+
console.log(chalk_1.default.dim(error.message));
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function handlePushFailure() {
|
|
59
|
+
console.log(chalk_1.default.red('Failed to push. You may need to set upstream branch.'));
|
|
60
|
+
const branch = (0, gitCommand_1.gitCommand)('rev-parse --abbrev-ref HEAD');
|
|
61
|
+
if (branch) {
|
|
62
|
+
console.log(chalk_1.default.dim(`Try: git push --set-upstream origin ${branch}`));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.log(chalk_1.default.dim('Try: git push --set-upstream origin <branch-name>'));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=push_to_remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push_to_remote.js","sourceRoot":"","sources":["../../src/utils/push_to_remote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,gDAUC;AAdD,4CAA4D;AAC5D,kDAA0B;AAC1B,6CAA0C;AAE1C,SAAsB,kBAAkB;;QACtC,MAAM,UAAU,GAAG,MAAM,IAAA,iBAAO,EAAC;YAC/B,OAAO,EAAE,4BAA4B;SACtC,CAAC,CAAC;QAEH,IAAI,IAAA,kBAAQ,EAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,OAAO;QACT,CAAC;QAED,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;CAAA;AAED,SAAe,WAAW;;QACxB,MAAM,WAAW,GAAG,IAAA,iBAAO,GAAE,CAAC;QAC9B,WAAW,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAE1C,yBAAyB;QACzB,MAAM,OAAO,GAAG,IAAA,uBAAU,EAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,WAAW,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,4CAA4C,CAAC,CAAC,CAAC;YACxE,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;YAEtC,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;gBACxB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAClC,iBAAiB,EAAE,CAAC;YACtB,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAClC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CAAA;AAED,SAAS,iBAAiB;IACxB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC,CAAC;IAE/E,MAAM,MAAM,GAAG,IAAA,uBAAU,EAAC,6BAA6B,CAAC,CAAC;IACzD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface FileChange {
|
|
2
|
+
status: string;
|
|
3
|
+
file: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GitChanges {
|
|
6
|
+
staged: FileChange[];
|
|
7
|
+
unstaged: FileChange[];
|
|
8
|
+
untracked: FileChange[];
|
|
9
|
+
}
|
|
10
|
+
export interface GitStatus {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
reason?: string;
|
|
13
|
+
}
|
|
14
|
+
export type CommitType = 'feat' | 'fix' | 'docs' | 'style' | 'refactor' | 'test' | 'chore' | 'deps' | 'config' | 'remove';
|
|
15
|
+
export interface CommitInfo {
|
|
16
|
+
type: CommitType;
|
|
17
|
+
scope?: string;
|
|
18
|
+
description: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "git-it-done",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"optimac": "./dist/index.js"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "ts-node ./src/index.ts",
|
|
9
|
+
"prod": "node ./dist/index.js",
|
|
10
|
+
"build": "tsc"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"description": "",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@clack/prompts": "^0.10.1",
|
|
21
|
+
"chalk": "^5.4.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.15.2",
|
|
25
|
+
"ts-node": "^10.9.2",
|
|
26
|
+
"typescript": "^5.8.3"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
AUTO - COMMITER
|
|
2
|
+
|
|
3
|
+
PS - its only for ongoing project, for new projects you need follow the instructions that Github provides:
|
|
4
|
+
|
|
5
|
+
echo "# AutoCommitter" >> README.md
|
|
6
|
+
git init
|
|
7
|
+
git add README.md
|
|
8
|
+
git commit -m "first commit"
|
|
9
|
+
git branch -M main
|
|
10
|
+
git remote add origin https://github.com/sidhxntt/AutoCommitter.git
|
|
11
|
+
git push -u origin main
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
so yes
|