Coder Social home page Coder Social logo

bitbucket-update-package-script's Introduction

bitbucket-update-script

Small CLI tool to create PR on bitbucket with updated package in dependencies or devDependencies package.jso.

Usage

I recommend to use node > 15

Install packages in root directory:

npm install

Then you can add CLI to your PATH by installing it locally:

npm install -global

after that you should be able to run CLI by:

bitbucket-update-script

You can also run it without installing by:

node ./src/index.js <comandName>

Setup authentication

before use create your .env file according to .env-example

Available commands

List of available commands can be always displayed by:

bitbucket-update-script -h bitbucket-update-script --help

updatePackage

Update package in dependencies or devDependencies in bitbucket repository. You can provide parameters by using options or interactive mode will ask for package name and version.

  -n --packageName <packageName>        name of package to update.
  -v --packageVersion <packageVersion>  target version.
  -w --workspace <workspace>            <optional> bitbucket workspace.
  -r --repository <repository>          <optional> bitbucket repository.
  -b --branch <branch>                  <optional> repository main branch.
  -h, --help                            display help for command

Example output:

Clone repo
redoc not found in devDependencies ./temp/create-pr-test-repo/package.json
update redoc to 2.0.0-rc.75 in ./temp/create-pr-test-repo/package.json
redoc not found in devDependencies ./temp/create-pr-test-repo/src/package.json
update redoc to 2.0.0-rc.75 in ./temp/create-pr-test-repo/src/package.json
wrong package.json format Unexpected token } in JSON at position 640
Commit changes
Push changes
Creating pull request
Pull request created successfully
Done

How it works:

  1. Clone repository using git
  2. Create local branch with name of package and version
  3. Recursive find package.json
  4. Try to parse all found package.json and return console log with error if package.json is not valid
  5. Update devDependencies and dependencies in package.json if packageName is found in package.json
  6. save package.json
  7. Commit changes using git
  8. Push changes using git
  9. Create pull request using bitbucket api

To Do

  • add support update package.json.lock in bitbucket
  • add support update yarn.lock in bitbucket
  • fix package.json formatting to fallow the original format
  • add support for cross workspace pull request
  • replace console log by logger
  • consider to fetch only package.json and package.json.lock files from bitbucket to avoid fetching all files from repository

bitbucket-update-package-script's People

Contributors

zalewskigrzegorz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.