git-push-time 1.1.0 → 1.1.1
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/.github/workflows/npm-publish.yml +33 -0
- package/README.md +215 -215
- package/bin/index.js +337 -291
- package/lib/commands/edit-time.js +141 -127
- package/lib/commands/fix.js +113 -105
- package/lib/commands/github.js +439 -436
- package/lib/commands/pull.js +89 -88
- package/lib/commands/push.js +673 -653
- package/lib/config.js +220 -210
- package/lib/fix.js +286 -260
- package/lib/git.js +492 -452
- package/lib/github.js +322 -304
- package/lib/prompt-helpers.js +62 -62
- package/lib/secrets.js +92 -87
- package/lib/ui.js +804 -844
- package/lib/utils.js +120 -106
- package/package.json +35 -32
package/bin/index.js
CHANGED
|
@@ -1,291 +1,337 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { select } from '@inquirer/prompts';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from '../lib/commands/github.js';
|
|
19
|
-
import { promptContinueOrBack } from '../lib/prompt-helpers.js';
|
|
20
|
-
import {
|
|
21
|
-
printBanner,
|
|
22
|
-
printDashboardStatus,
|
|
23
|
-
printSection,
|
|
24
|
-
printGitMissing,
|
|
25
|
-
printCancelled,
|
|
26
|
-
styleCliHelp
|
|
27
|
-
} from '../lib/ui.js';
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
.
|
|
240
|
-
.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
.
|
|
247
|
-
.
|
|
248
|
-
.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
.
|
|
265
|
-
.
|
|
266
|
-
.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
.
|
|
285
|
-
.
|
|
286
|
-
.action(async (
|
|
287
|
-
printBanner(VERSION);
|
|
288
|
-
await
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { select } from '@inquirer/prompts';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { checkGitInstalled, getCurrentBranch } from '../lib/git.js';
|
|
9
|
+
import { getCurrentGitHubUser } from '../lib/github.js';
|
|
10
|
+
import { runPushWizard } from '../lib/commands/push.js';
|
|
11
|
+
import { runPullCommand } from '../lib/commands/pull.js';
|
|
12
|
+
import { runEditCommitTimeCommand } from '../lib/commands/edit-time.js';
|
|
13
|
+
import { runFixCommand } from '../lib/commands/fix.js';
|
|
14
|
+
import {
|
|
15
|
+
runGitHubMenu,
|
|
16
|
+
promptCreateRepo,
|
|
17
|
+
showUserRepos,
|
|
18
|
+
} from '../lib/commands/github.js';
|
|
19
|
+
import { promptContinueOrBack } from '../lib/prompt-helpers.js';
|
|
20
|
+
import {
|
|
21
|
+
printBanner,
|
|
22
|
+
printDashboardStatus,
|
|
23
|
+
printSection,
|
|
24
|
+
printGitMissing,
|
|
25
|
+
printCancelled,
|
|
26
|
+
styleCliHelp
|
|
27
|
+
} from '../lib/ui.js';
|
|
28
|
+
|
|
29
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
30
|
+
const __dirname = path.dirname(__filename);
|
|
31
|
+
|
|
32
|
+
function getPackageVersion() {
|
|
33
|
+
try {
|
|
34
|
+
const raw = fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8');
|
|
35
|
+
return JSON.parse(raw).version || '1.1.0';
|
|
36
|
+
} catch {
|
|
37
|
+
return '1.1.0';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const VERSION = getPackageVersion();
|
|
42
|
+
|
|
43
|
+
function isExitPromptError(err) {
|
|
44
|
+
const msg = String(err?.message || '');
|
|
45
|
+
return (
|
|
46
|
+
err?.name === 'ExitPromptError' ||
|
|
47
|
+
msg.includes('User force closed the prompt') ||
|
|
48
|
+
msg.includes('SIGINT')
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Kiểm tra xem lệnh có được gọi "trần" (không flag/subcommand nào) hay không.
|
|
54
|
+
*/
|
|
55
|
+
function isBareInvocation(options = {}) {
|
|
56
|
+
return (
|
|
57
|
+
!options.repo &&
|
|
58
|
+
!options.message &&
|
|
59
|
+
!options.date &&
|
|
60
|
+
!options.branch &&
|
|
61
|
+
!options.dir &&
|
|
62
|
+
!options.force &&
|
|
63
|
+
!options.fix
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Menu chính khi chạy `git-push-time` không truyền flag
|
|
69
|
+
*/
|
|
70
|
+
async function promptMainMenu() {
|
|
71
|
+
printSection('BẢNG ĐIỀU KHIỂN CHÍNH');
|
|
72
|
+
return await select({
|
|
73
|
+
message: 'Bạn muốn thực hiện thao tác nào?',
|
|
74
|
+
pageSize: 10,
|
|
75
|
+
choices: [
|
|
76
|
+
{
|
|
77
|
+
name: 'Đẩy dự án lên Git',
|
|
78
|
+
value: 'push',
|
|
79
|
+
description: 'Chọn repository, thời gian commit và đẩy code'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Quản lý GitHub',
|
|
83
|
+
value: 'github',
|
|
84
|
+
description: 'Tạo repository, xem tài khoản và quản lý kết nối'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'Pull code mới',
|
|
88
|
+
value: 'pull',
|
|
89
|
+
description: 'Cập nhật branch hiện tại từ remote'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'Sửa thời gian commit',
|
|
93
|
+
value: 'edit-time',
|
|
94
|
+
description: 'Chọn commit trong lịch sử và cập nhật ngày giờ'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Quét secret',
|
|
98
|
+
value: 'fix',
|
|
99
|
+
description: 'Tìm file nhạy cảm trước khi đẩy code'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'Thoát',
|
|
103
|
+
value: 'exit',
|
|
104
|
+
description: 'Thoát ứng dụng'
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Vòng lặp Menu chính (không đệ quy — callback back chỉ trả sentinel)
|
|
112
|
+
*/
|
|
113
|
+
async function runMainMenuLoop(initialOptions = {}) {
|
|
114
|
+
while (true) {
|
|
115
|
+
const cwd = process.cwd();
|
|
116
|
+
let branch = 'main';
|
|
117
|
+
try {
|
|
118
|
+
branch = getCurrentBranch(cwd);
|
|
119
|
+
} catch {}
|
|
120
|
+
let ghStatus = { authenticated: false };
|
|
121
|
+
try {
|
|
122
|
+
ghStatus = await getCurrentGitHubUser();
|
|
123
|
+
} catch {
|
|
124
|
+
ghStatus = { authenticated: false };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
printDashboardStatus({
|
|
128
|
+
targetDir: cwd,
|
|
129
|
+
currentBranch: branch,
|
|
130
|
+
githubUser: ghStatus.authenticated ? ghStatus.user : null
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
let action;
|
|
134
|
+
try {
|
|
135
|
+
action = await promptMainMenu();
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (isExitPromptError(err)) {
|
|
138
|
+
printCancelled();
|
|
139
|
+
process.exit(0);
|
|
140
|
+
}
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (action === 'exit') {
|
|
145
|
+
printCancelled();
|
|
146
|
+
process.exit(0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
if (action === 'push') {
|
|
151
|
+
const res = await runPushWizard(initialOptions, async () => 'back');
|
|
152
|
+
// 'back' = user muốn về menu → tiếp tục loop; ngược lại push xong thì thoát
|
|
153
|
+
if (res === 'back') continue;
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (action === 'github') {
|
|
158
|
+
const ghResult = await runGitHubMenu({ defaultDir: cwd });
|
|
159
|
+
if (ghResult && ghResult.autoPush && ghResult.repoUrl) {
|
|
160
|
+
// Sau khi tạo repo mới, chuyển tiếp thẳng vào luồng push
|
|
161
|
+
const res = await runPushWizard({ ...initialOptions, repo: ghResult.repoUrl }, async () => 'back');
|
|
162
|
+
if (res === 'back') continue;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
} else if (action === 'pull') {
|
|
166
|
+
await runPullCommand('origin', undefined, { fromMenu: true });
|
|
167
|
+
} else if (action === 'edit-time') {
|
|
168
|
+
await runEditCommitTimeCommand({ fromMenu: true });
|
|
169
|
+
} else if (action === 'fix') {
|
|
170
|
+
await runFixCommand({ fromMenu: true });
|
|
171
|
+
}
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (isExitPromptError(err)) {
|
|
174
|
+
printCancelled();
|
|
175
|
+
process.exit(0);
|
|
176
|
+
}
|
|
177
|
+
throw err;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let next;
|
|
181
|
+
try {
|
|
182
|
+
next = await promptContinueOrBack('Hoàn tất! Bạn muốn tiếp tục hay quay lại bảng điều khiển?');
|
|
183
|
+
} catch (err) {
|
|
184
|
+
if (isExitPromptError(err)) {
|
|
185
|
+
printCancelled();
|
|
186
|
+
process.exit(0);
|
|
187
|
+
}
|
|
188
|
+
throw err;
|
|
189
|
+
}
|
|
190
|
+
if (next === 'exit') {
|
|
191
|
+
process.exit(0);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async function main(options = {}) {
|
|
197
|
+
printBanner(VERSION);
|
|
198
|
+
|
|
199
|
+
if (!checkGitInstalled()) {
|
|
200
|
+
printGitMissing();
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const isInteractive = !options.yes;
|
|
205
|
+
|
|
206
|
+
if (isInteractive && isBareInvocation(options)) {
|
|
207
|
+
try {
|
|
208
|
+
await runMainMenuLoop(options);
|
|
209
|
+
} catch (err) {
|
|
210
|
+
if (isExitPromptError(err)) {
|
|
211
|
+
printCancelled();
|
|
212
|
+
process.exit(0);
|
|
213
|
+
}
|
|
214
|
+
throw err;
|
|
215
|
+
}
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Chạy trực tiếp push wizard với các options được cung cấp
|
|
220
|
+
try {
|
|
221
|
+
await runPushWizard(options);
|
|
222
|
+
} catch (err) {
|
|
223
|
+
if (isExitPromptError(err)) {
|
|
224
|
+
printCancelled();
|
|
225
|
+
process.exit(0);
|
|
226
|
+
}
|
|
227
|
+
throw err;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* ==========================================================================
|
|
232
|
+
COMMANDER CLI CONFIGURATION
|
|
233
|
+
========================================================================== */
|
|
234
|
+
|
|
235
|
+
const program = new Command();
|
|
236
|
+
styleCliHelp(program);
|
|
237
|
+
|
|
238
|
+
program
|
|
239
|
+
.name('git-push-time')
|
|
240
|
+
.description('Bộ công cụ Git & GitHub CLI: Đẩy code siêu tốc, kết nối GitHub tạo repo, chỉnh thời gian commit và bảo vệ secret')
|
|
241
|
+
.version(VERSION)
|
|
242
|
+
.option('-r, --repo <url>', 'Đường dẫn Git repository (URL hoặc để trống để chọn/tạo mới)')
|
|
243
|
+
.option('-d, --date <datetime>', 'Thời gian commit (VD: "2024-01-15 14:30:00", "-2d", "-5h", "now")')
|
|
244
|
+
.option('-m, --message <msg>', 'Thông điệp commit (Commit message)')
|
|
245
|
+
.option('-b, --branch <branch>', 'Tên branch trên remote (Mặc định: main)')
|
|
246
|
+
.option('-C, --dir <path>', 'Thư mục nguồn cần push (Mặc định: thư mục hiện tại)')
|
|
247
|
+
.option('-f, --force', 'Thực hiện push đè (--force)', false)
|
|
248
|
+
.option('-y, --yes', 'Bỏ qua giao diện hỏi, tự động dùng tham số hoặc giá trị mặc định', false)
|
|
249
|
+
.option('--fix', 'Tự động gỡ file secret khỏi stage & thêm .gitignore (an toàn, không xóa file thật)', false)
|
|
250
|
+
.action(async (opts) => {
|
|
251
|
+
await main(opts);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// LỆNH GITHUB
|
|
255
|
+
const ghCmd = program
|
|
256
|
+
.command('github')
|
|
257
|
+
.description('Quản lý tài khoản GitHub và tạo repository mới trực tiếp')
|
|
258
|
+
.action(async () => {
|
|
259
|
+
printBanner(VERSION);
|
|
260
|
+
await runGitHubMenu();
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
ghCmd
|
|
264
|
+
.command('create')
|
|
265
|
+
.description('Tạo repository mới trên GitHub (Public hoặc Private)')
|
|
266
|
+
.option('-C, --dir <path>', 'Thư mục nguồn cần liên kết')
|
|
267
|
+
.action(async (opts) => {
|
|
268
|
+
printBanner(VERSION);
|
|
269
|
+
const res = await promptCreateRepo({ targetDir: opts.dir || process.cwd() });
|
|
270
|
+
if (res.ok && res.repo) {
|
|
271
|
+
console.log(`\n » Repo URL: ${res.repo.cloneUrl}\n`);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
ghCmd
|
|
276
|
+
.command('whoami')
|
|
277
|
+
.description('Xem thông tin tài khoản GitHub đang kết nối')
|
|
278
|
+
.action(async () => {
|
|
279
|
+
printBanner(VERSION);
|
|
280
|
+
await showGitHubStatus();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
ghCmd
|
|
284
|
+
.command('repos')
|
|
285
|
+
.description('Liệt kê danh sách repository trên GitHub của bạn')
|
|
286
|
+
.action(async () => {
|
|
287
|
+
printBanner(VERSION);
|
|
288
|
+
await showUserRepos();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
ghCmd
|
|
292
|
+
.command('login')
|
|
293
|
+
.description('Đăng nhập tài khoản GitHub bằng OAuth Device Flow hoặc Token')
|
|
294
|
+
.action(async () => {
|
|
295
|
+
printBanner(VERSION);
|
|
296
|
+
await promptGitHubLogin();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
ghCmd
|
|
300
|
+
.command('logout')
|
|
301
|
+
.description('Đăng xuất tài khoản GitHub khỏi máy')
|
|
302
|
+
.action(async () => {
|
|
303
|
+
printBanner(VERSION);
|
|
304
|
+
logoutGitHub();
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// LỆNH FIX
|
|
308
|
+
program
|
|
309
|
+
.command('fix')
|
|
310
|
+
.description('Quét & tự động gỡ file secret khỏi stage, cập nhật .gitignore và làm sạch commit unpushed')
|
|
311
|
+
.option('-C, --dir <path>', 'Thư mục cần quét fix (Mặc định: thư mục hiện tại)')
|
|
312
|
+
.action(async (opts) => {
|
|
313
|
+
printBanner(VERSION);
|
|
314
|
+
await runFixCommand(opts);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// LỆNH PULL
|
|
318
|
+
program
|
|
319
|
+
.command('pull [remote] [branch]')
|
|
320
|
+
.description('Cập nhật code từ remote bằng fast-forward --ff-only hoặc --rebase')
|
|
321
|
+
.option('-C, --dir <path>', 'Thư mục repo cần pull (Mặc định: thư mục hiện tại)')
|
|
322
|
+
.action(async (remote, branch, opts) => {
|
|
323
|
+
printBanner(VERSION);
|
|
324
|
+
await runPullCommand(remote || 'origin', branch, opts || {});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// LỆNH EDIT-TIME
|
|
328
|
+
program
|
|
329
|
+
.command('edit-time')
|
|
330
|
+
.description('Sửa thời gian của commit lịch sử (Backdate commit hash)')
|
|
331
|
+
.option('-C, --dir <path>', 'Thư mục repo (Mặc định: thư mục hiện tại)')
|
|
332
|
+
.action(async (opts) => {
|
|
333
|
+
printBanner(VERSION);
|
|
334
|
+
await runEditCommitTimeCommand(opts);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
program.parse(process.argv);
|