Skip to content

Latest commit

 

History

History
337 lines (264 loc) · 13.5 KB

README.md

File metadata and controls

337 lines (264 loc) · 13.5 KB

Open in Visual Studio Code

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

myawesometool

A CLI tool to automatically check for dependency of a specified package and then create a PR updating the package.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Automatic Pull requests like below

Product Name Screen Shot

Currently works with only github.

This project is about building a simple CLI tool that will look through a file(currently only .csv file) and let the user know about the version of specified dependency of a project/repo listed in the file. It also writes the same info onto another file.

The link to the repository can be any one of the following format: (taken straight out of github-url-to-object page)

  * 'github:monkey/business'
  * 'https://github.com/monkey/business'
  * 'https://github.com/monkey/business/tree/master'
  * 'github:monkey/business#nachos'
  * 'https://github.com/monkey/business/tree/master/nested/file.js'
  * 'https://github.com/monkey/business.git'
  * 'http://github.com/monkey/business'
  * 'git://github.com/monkey/business.git'
  * 'git+https://github.com/monkey/business.git'

In addition to the above mentioned task if the version is below specified version it'll automatically fork, clone, update, push and create a PR to the original repo. Provided we tell it to do so.

(back to top)

Built With

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

In order to use this project/ repo / tool there are certain pre-requisites.

  • node
  • npm
    npm install npm@latest -g
  • A code Editor (e.g., Visual Studio, VS Code, Sublime Text, Atom etc.)

Installation

  1. Get your personal access token from github(required only when using the -u option. Not required for the -i option). Follow this for creating your PAT(Personal Access Token) Creating a personal access token
  2. Clone the repo
    git clone https://github.com/dyte-submissions/dyte-vit-2022-Aritra779.git
  3. Install NPM packages
    npm install
  4. (Optionally required for -u option) Enter your PAT(Personal Access Token) in a .env file in G_TOKEN variable. Change the name everywhere if you wish.
    G_TOKEN = 'ENTER YOUR PAT'
    

(back to top)

How to use

  • Move into the project directory from command line / shell / bash

    cd dyte-vit-2022-Aritra779
  • For help run

    myawesometool -h

    or

    myawesometool --help
  • For reading a CSV file and listing out dependency version satisfiability status run

    myawesometool -i <somefile.csv> <package_name@version>
  • For creating an automated PR(pull request) along with the above task run

    myawesometool -update -i <somefile.csv> <package_name@version>

    This requires github PAT(Personal Access Token).

    Also note that this will not update the mentioned package if the mentioned version isn't in the compatibility range mentioned in the package.json

  • For forcefully updating a package even if it might break certain features run

    myawesometool -i -u -f <somefile.csv> <package_name@version>
  • For starting at a specified row index run

    myawesometool -i -s4 <somefile.csv> <package_name@version>

    OR

    myawesometool -i --start=4 <somefile.csv> <package_name@version>

    If the csv file has no header then pass --start=-1

  • If you own all the repositories mentioned in the csv file or if you have write access or branch creation access to them then run

    myawesometool -i -u -o <somefile.csv> <package_name@version>

    Use this option when forking isn't necessary.

    Currently mixture of self owned and not owned repository cannot be process together. Best action plan in that case would be to keep them in two differnt files and then use the tool.

  • npm test

    currently has only 4 tests. Fork test and Pull test test the correspoding API calls. The API call is mocked. You can test it out without a worry. The other two tests are for testing out API call to get the package.json file of any repo. These two calls are also mocked. Hence you can test it out without a single worry.

  • Don't run it outside of the project directory for the time being (will be looked into later)

  • This tool expects the first column of the csv file to be the name of the repository, the second column to be the link of the repository. It'll also add the version in the 3rd column, version satisfiability condition in 4th column and the generated PR link in the 5th column.

  • Note: After the task has been performed the auto generated directory named Temporary_Directory will be automatically deleted. But this takes some time, huge lot of time in some cases. Also it doesn't report the deletion progress. It'll only report when there's an error or when the complete deletion task is done. If you don't want to wait around for the deletion task then it's best to stop the process there and manually delete the directory. No harm will be done to the overall task since the core task has already been completed by that time.

  • There's a sample_d.csv file with two repo links. First repo (named test) have axios 0.25.0 and react 18.0.0. Second one doesn't have react but have axios 0.23.0. So for testing PR generation test with anything higher than the specified versions.

Usage

i option Screen Shot with lower version

i option Screen Shot with higher version

npm test Screen Shot

-u Option Screen Shot1

-u Option Screen Shot2

-u Option Screen Shot3

(back to top)

Roadmap

  • Basic Documention (High Priority)
  • More Documention (When More Features Arrive)
  • npm test (Normal Priority)
  • Move from 'have to work anyhow' to 'should be logically sound' (High Priority)
  • Reduce dependency (Low Priority)
    • csv-parser (Low Priority)
    • csv-writer (Low Priority)
    • get-repo-package-json (High Priority)
    • github-url-to-object (Not Likely)
    • chalk (probably Not)
    • commander (When there's a better option available)
  • Robustness (Normal Priority)
  • More features I can't think of right now (Low Priority)

(back to top)

Changelog

v1.2.0

  • Added an additional flag -s | --start for specifying which row (0 indexed) of the file to start execution from
  • Added an additional flag -o | --own for specifying whether the user owns all the repository listed in the csv file. If this flag is passed forking won't be done.
  • Added a request limit checking logic that'll automatically stop the execution if the request limit per hour (according to github API) is about to be reached.
  • Added a condition that'll check if the github PAT is defined in .env file under G_TOKEN variable. If not then using -u | --update will not perform the said task.

See the full list of changelog listed on CHANGELOG.md

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Aritra Dutta - aritra.dutta.366@gmail.com

Project Link: https://github.com/dyte-submissions/dyte-vit-2022-Aritra779

(back to top)

Acknowledgments

(back to top)