0.3.0 • Published 10 months ago

@aglstudio/versionbumper v0.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

versionBumper

versionBumper is a simple CLI tool designed to help you manage and track versions in your project. It automates the process of updating version numbers in your package.json and optionally in your .env file, and it also commits and pushes these changes to your Git repository.

Features

  • Increment version numbers in package.json (major, minor, patch).
  • Optionally update version numbers in a specified .env file.
  • Support for multiple subprojects within a monorepo structure.
  • Ability to update specific projects independently with different version numbers.
  • Automatically commit and push changes to your Git repository with a custom commit message.
  • Configurable through a versionBump.conf.json file.

Installation

To install versionBumper, you need to have Node.js and npm installed. Then, you can install it globally using npm:

npm install -g @aglstudio/versionbumper
or
npm install @aglstudio/versionbumper --save-dev

Configuration

You can configure versionBumper using a versionBump.conf.json file in the root of your project. Here is an example configuration:

{
  "changeEnv": true,
  "envVersionValue": "VERSION",
  "envVersionFile": ".env"
}

For more advanced configurations with subprojects:

{
  "files": [
    {
      "path": "package.json",
      "type": "json",
      "field": "version"
    },
    {
      "path": ".env",
      "type": "env",
      "key": "VERSION"
    }
  ],
  "subprojects": [
    {
      "dir": "client",
      "files": [
        {
          "path": "package.json",
          "type": "json",
          "field": "version"
        },
        {
          "path": ".env",
          "type": "env",
          "key": "NEXT_PUBLIC_VERSION"
        }
      ]
    },
    {
      "dir": "server",
      "files": [
        {
          "path": "package.json",
          "type": "json",
          "field": "version"
        },
        {
          "path": ".env",
          "type": "env",
          "key": "API_VERSION"
        }
      ]
    }
  ],
  "skipGitCheck": true
}

Configuration options:

  • changeEnv: (boolean) Whether to update the version in the .env file.
  • envVersionValue: (string) The key in the .env file that holds the version number.
  • envVersionFile: (string) The path to the .env file.
  • files: (array) List of files to update in the root directory.
  • subprojects: (array) List of subprojects with their own files to update.
    • dir: (string) The directory containing the subproject.
    • files: (array) List of files to update in the subproject.
  • skipGitCheck: (boolean) Skip Git operations.

Usage

To use versionBumper, navigate to your project directory and run:

versionBumper [options]

Options:

  • --config, -c: Specify a custom path to the configuration file (default: versionBump.conf.json)
  • --project, -p: Specify which project(s) to update. Can be used multiple times for multiple projects. Use 'main' for the root project. If not specified, all projects will be prompted for selection.

Examples:

versionBumper
versionBumper --config ./config/my-version-bump.json
versionBumper -c ../shared-config.json
versionBumper --project client
versionBumper -p client -p server

You will be prompted to select the type of version change (major, minor, patch) and to enter a commit message. If changeEnv is not specified in the configuration file, you will also be asked if you want to update the .env file.

If you have subprojects defined and don't specify which projects to update via command line, you'll be prompted to select which projects should be updated.

Example

  • Run the command:
versionBumper
  • Select the type of version change:
? What type of change? (Use arrow keys)
❯ major
  minor
  patch
  • If you have subprojects, you'll be prompted to select which ones to update:
? Which projects to update? (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯ ◉ main
  ◉ client
  ◉ server
  • Enter the commit message:
? Enter the commit message: Updated version to 1.0.0

If changeEnv is not specified in the configuration file, you will be asked:

? Do you want to update the .env file? (Y/n)

How It Works

  • Configuration Check: The tool reads the configuration from versionBump.conf.json using the checkForConf function.
  • Project Selection: It determines which projects to update based on command line arguments or interactive prompts.
  • Version Update: It updates the version in package.json and other specified files independently for each selected project.
  • Environment File Update: If configured, it updates the version in the .env file using the updateEnv function.
  • Git Operations: It commits and pushes the changes to the Git repository with version information for each updated project.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the ISC License. See the LICENSE file for details.

Contact

For any questions or issues, please open an issue on GitHub.

Acknowledgements

  • inquirer
  • simple-git
0.1.10

1 year ago

0.1.11

1 year ago

0.3.0

10 months ago

0.2.1

1 year ago

0.2.8

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.4

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago