bbump 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.
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="corretto-21" project-jdk-type="JavaSDK">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/bumpb.iml" filepath="$PROJECT_DIR$/.idea/bumpb.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Bump Version based on branch prefix
2
+ > Smart version bumper for npm packages with branch-aware defaults
3
+
4
+ `bbump`, the prefix `b` represents `branch`
5
+
6
+ [![npm version](https://img.shields.io/npm/v/bbump)](https://www.npmjs.com/package/bbump)
7
+ [![license](https://img.shields.io/npm/l/bbump)](LICENSE)
8
+
9
+ ## Features
10
+
11
+ - Interactive prompt for version selection
12
+ - Automatically suggests version bump type (`minor` or `patch`) based on branch prefix
13
+ - Creates a standardized commit with only `package.json` and `yarn.lock`/`package-lock.json`
14
+ - Works with both npm and yarn
15
+ - Zero configuration required
16
+
17
+ ## Installation
18
+
19
+ You can use `npx bbump` without installation (recommended). This way, you can always get latest version.
20
+
21
+ Or Install it as a dev dependency:
22
+
23
+ ```bash
24
+ npm install -D bbump
25
+ ```
26
+ or
27
+ ```bash
28
+ yarn add -D bbump
29
+ ```
30
+
31
+ ## Usage
32
+ Run in your project directory:
33
+
34
+ ```bash
35
+ npx bbump
36
+ ```
37
+
38
+ Or add `script` to your `package.json`:
39
+ ```json
40
+ {
41
+ "scripts": {
42
+ "bumpVersion": "npx bbump"
43
+ }
44
+ }
45
+ ```
46
+
47
+ Or if you installed as dev dependency:
48
+ ```json
49
+ {
50
+ "scripts": {
51
+ "bumpVersion": "bbump"
52
+ }
53
+ }
54
+ ```
55
+
56
+ ## How It Works
57
+ The tool follows this logic:
58
+
59
+ 1. Branch Detection
60
+ - `feat/`, `feature/`, `minor/` prefixes → `minor` bump
61
+ - All others → `patch` bump
62
+
63
+ 2. Package Manager
64
+ Automatically detects whether to use `npm version` or `yarn version`
65
+
66
+ 3. Git Integration
67
+ Commits only `package.json` and the lockfile with message:
68
+ `"chore: bump version"`
69
+
70
+ ## Contributing
71
+ PRs are welcome! Please open an issue first to discuss proposed changes.
72
+
73
+ ## License
74
+ MIT © helloint
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "bbump",
3
+ "version": "1.0.0",
4
+ "description": "Bump version based on branch prefix",
5
+ "main": "src/index.mjs",
6
+ "bin": {
7
+ "bbump": "src/index.mjs"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "author": "helloint",
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "inquirer": "^9.0.0"
16
+ }
17
+ }
package/src/index.mjs ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ import { execSync } from 'child_process';
3
+ import { existsSync } from 'fs';
4
+ import inquirer from 'inquirer';
5
+
6
+ // Check if the project uses Yarn (by checking for yarn.lock)
7
+ const isYarn = existsSync('yarn.lock');
8
+
9
+ // Get the current branch name
10
+ const currentBranch = execSync('git branch --show-current', { encoding: 'utf-8' }).trim();
11
+
12
+ // Determine the default version type based on the branch prefix
13
+ const isFeatureBranch = currentBranch.startsWith('feat');
14
+ const defaultVersionType = isFeatureBranch ? 'minor' : 'patch';
15
+
16
+ // Define version bump options
17
+ const questions = [
18
+ {
19
+ type: 'list',
20
+ name: 'versionType',
21
+ message: 'Select the version type to bump:',
22
+ choices: ['minor', 'patch'],
23
+ default: defaultVersionType, // Dynamic default based on branch prefix
24
+ },
25
+ ];
26
+
27
+ // Prompt the user for selection
28
+ const { versionType } = await inquirer.prompt(questions);
29
+
30
+ try {
31
+ // Execute version command based on the package manager
32
+ const versionCommand = isYarn
33
+ ? `yarn version --${versionType} --no-git-tag-version`
34
+ : `npm version ${versionType} --no-git-tag-version`;
35
+ execSync(versionCommand, { stdio: 'inherit' });
36
+
37
+ // Add only package.json and lockfile to Git
38
+ const lockfile = isYarn ? 'yarn.lock' : 'package-lock.json';
39
+ execSync(`git add package.json ${lockfile}`, { stdio: 'inherit' });
40
+
41
+ // Commit only the specified files with a fixed commit message
42
+ execSync(`git commit -m "chore: bump version" package.json ${lockfile}`, { stdio: 'inherit' });
43
+
44
+ console.log(`Version bumped to ${versionType} and changes committed with message: 'chore: bump version'.`);
45
+ } catch (error) {
46
+ console.error('Failed to bump version or commit changes:', error.message);
47
+ process.exit(1);
48
+ }