cherrypick-interactive 1.8.1 → 1.9.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.
Files changed (2) hide show
  1. package/cli.js +26 -1
  2. package/package.json +1 -1
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))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cherrypick-interactive",
3
- "version": "1.8.1",
3
+ "version": "1.9.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",