cherrypick-interactive 1.8.1 → 1.10.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/cli.js CHANGED
@@ -30,7 +30,32 @@ if (upd && semver.valid(upd.latest) && semver.valid(pkg.version) && semver.gt(up
30
30
  console.log('');
31
31
  console.log(chalk.yellow('⚠️ A new version is available'));
32
32
  console.log(chalk.gray(` ${name}: ${chalk.red(pkg.version)} → ${chalk.green(upd.latest)}`));
33
- console.log(chalk.cyan(` Update with: ${chalk.bold(`npm i -g ${name}`)}\n`));
33
+
34
+ // Skip interactive prompt in CI or non-TTY
35
+ if (process.stdout.isTTY && !process.env.CI) {
36
+ const { shouldUpdate } = await inquirer.prompt([
37
+ {
38
+ type: 'confirm',
39
+ name: 'shouldUpdate',
40
+ message: `Update to ${upd.latest} now?`,
41
+ default: false,
42
+ },
43
+ ]);
44
+ if (shouldUpdate) {
45
+ const { execSync } = await import('node:child_process');
46
+ console.log(chalk.cyan(`\nUpdating ${name}...`));
47
+ try {
48
+ execSync(`npm i -g ${name}@${upd.latest}`, { stdio: 'inherit' });
49
+ console.log(chalk.green(`✓ Updated to ${upd.latest}. Please re-run the command.\n`));
50
+ process.exit(0);
51
+ } catch {
52
+ console.error(chalk.red('Update failed. Please update manually:'));
53
+ console.error(chalk.cyan(` npm i -g ${name}\n`));
54
+ }
55
+ }
56
+ } else {
57
+ console.log(chalk.cyan(` Update with: ${chalk.bold(`npm i -g ${name}`)}\n`));
58
+ }
34
59
  }
35
60
 
36
61
  const argv = yargs(hideBin(process.argv))
@@ -258,16 +283,16 @@ async function getSubjects(branch) {
258
283
  }
259
284
 
260
285
  async function getDevCommits(branch, since) {
261
- const out = await gitRaw(['log', '--no-merges', `--since=${since}`, '--pretty=%H %s', branch]);
286
+ const SEP = '|||';
287
+ const out = await gitRaw(['log', '--no-merges', `--since=${since}`, `--pretty=%H${SEP}%ar${SEP}%s`, branch]);
262
288
 
263
289
  if (!out) {
264
290
  return [];
265
291
  }
266
292
  return out.split('\n').map((line) => {
267
- const firstSpace = line.indexOf(' ');
268
- const hash = line.slice(0, firstSpace);
269
- const subject = line.slice(firstSpace + 1);
270
- return { hash, subject };
293
+ const [hash, date, ...rest] = line.split(SEP);
294
+ const subject = rest.join(SEP);
295
+ return { hash, subject, date: date || '' };
271
296
  });
272
297
  }
273
298
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cherrypick-interactive",
3
- "version": "1.8.1",
3
+ "version": "1.10.0",
4
4
  "description": "Interactively cherry-pick commits that are in dev but not in main, using subject-based comparison.",
5
5
  "main": "cli.js",
6
6
  "bin": "cli.js",
@@ -15,6 +15,7 @@ export function CommitList({ commits, selected, cursorIndex }) {
15
15
  key=${c.hash}
16
16
  hash=${c.hash}
17
17
  subject=${c.subject}
18
+ date=${c.date || ''}
18
19
  isSelected=${selected.has(c.hash)}
19
20
  isCursor=${start + i === cursorIndex}
20
21
  />
@@ -1,7 +1,7 @@
1
- import { Text, Box } from 'ink';
1
+ import { Text, Box, Spacer } from 'ink';
2
2
  import { html } from './html.js';
3
3
 
4
- export function CommitRow({ hash, subject, isSelected, isCursor }) {
4
+ export function CommitRow({ hash, subject, date, isSelected, isCursor }) {
5
5
  const checkbox = isSelected ? '☑' : '☐';
6
6
  const checkColor = isSelected ? 'green' : 'gray';
7
7
  const cursor = isCursor ? '>' : ' ';
@@ -13,7 +13,9 @@ export function CommitRow({ hash, subject, isSelected, isCursor }) {
13
13
  <${Text} color=${cursorColor}>${cursor} </${Text}>
14
14
  <${Text} color=${checkColor}>${checkbox} </${Text}>
15
15
  <${Text} color="dim">${hash.slice(0, 7)} </${Text}>
16
- <${Text} color=${subjectColor}>${subject}</${Text}>
16
+ <${Text} color=${subjectColor} wrap="truncate">${subject}</${Text}>
17
+ <${Spacer} />
18
+ <${Text} color="dim">${date}</${Text}>
17
19
  </${Box}>
18
20
  `;
19
21
  }
package/src/tui/Header.js CHANGED
@@ -3,11 +3,11 @@ import { html } from './html.js';
3
3
 
4
4
  export function Header({ devBranch, mainBranch, commitCount, since }) {
5
5
  return html`
6
- <${Box} borderStyle="single" borderColor="cyan" paddingX=${1}>
7
- <${Text} color="cyan">${devBranch} → ${mainBranch}</${Text}>
8
- <${Text}> </${Text}>
6
+ <${Box} paddingX=${1}>
7
+ <${Text} color="cyan" bold>${devBranch} → ${mainBranch}</${Text}>
8
+ <${Text} color="gray"> | </${Text}>
9
9
  <${Text} color="yellow">${commitCount} missing</${Text}>
10
- <${Text}> </${Text}>
10
+ <${Text} color="gray"> | </${Text}>
11
11
  <${Text} color="gray">Since: ${since}</${Text}>
12
12
  </${Box}>
13
13
  `;