0.0.5 • Published 2 years ago

@eggsy001/npm-verify v0.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Open in Visual Studio Code

Contributors Forks Stargazers Issues MIT License LinkedIn

About The Project

Product Name Screen Shot A Node.js script for the linux and macOS environments that can be used by node.js developers to check among a list of given repositories:

  • whether the installed version of a specified package meets the specified version criteria or not.
  • create a pull request if the version criteria doesn't match.
  • generate a report containing the results and links for PRs(if any).

Created as a submission for The SDK Tooling Challenge, Dyte's 2022 on-campus hiring process at VIT Bhopal University.

Built With

Getting Started

Prerequisites

Installation

  1. Create a github personal access token that meets at-least the following access requirements. Refer: Creating a Personal Access Token:

    • repo
      • repo:status Access commit status
      • repo_deployment Access deployment status
      • public_repo Access public repositories
      • repo:invite Access repository invitations
      • security_events
    • admin:org
      • write:org
      • read:org
    • user
      • read:user
      • user:email
      • user:follow

    Copy the resultant token for later use in a retrievable place. Note that it is lost upon reloading again after it's created.

  2. Clone the repo

    git clone https://github.com/dyte-submissions/dyte-vit-2022-AndroAvi.git
  3. Install NPM packages
    npm install
  4. Make installed package globally available
    npm link
  5. Alternatively, skip steps 2-4 and
    npm install -g @eggsy001/npm-verify
    to install the published npm package directly.
  6. Verify installation
    npm-verify --help
    Should return the following output: image

Usage

Checking the dependency versions

  1. Make sure that the input file is in the .csv format and is located in the current working directory. If not, open a new terminal in the directory of the input file, or
    cd "PATH" #path is the path from cwd to input file.
  2. run
       npm-verify -i "INPUT_FILE_NAME.csv" -t "GITHUB_PERSONAL ACCESS_TOKEN" "PACKAGE_NAME"@"PACKAGE_VERSION"
  3. Wait for the finish message. The output file output.csv would now be created in the cwd.

Creating update PR for version mismatches

  1. Again, make sure that the input file is in the cwd.
  2. run:
        npm-verify -i "INPUT_FILE_NAME.csv" -t "GITHUB_PERSONAL ACCESS_TOKEN" "PACKAGE_NAME"@"PACKAGE_VERSION" -u
  3. Wait for the finish message. The output file output.csv created this time would contain the links to the PRs in the respective repositories.

    Note that if you don't have write access to a repository in the link, it is automatically forked to the account associated with the github personal access token.

Changing output file name

To change the output file name, pass the optional flag -o or --output with the previous commands, e.g.

npm-verify -i "INPUT_FILE_NAME.csv" -t "GITHUB_PERSONAL ACCESS_TOKEN" "PACKAGE_NAME"@"PACKAGE_VERSION" -u -o  "OUTPUT_FILE_NAME.csv"

Refer to the following command for details on flags.

npm-verify --help

Demonstration

gif

Input And Output Formats

Specifications

Input

  • The project assumes as input a .csv with column titles present.
  • The first column should be titled name, and the second repo.
  • The name column contains the name of the repo.
  • The repo column should contain a standard github repo link of the format https://github.com/{owner}/{repo_name}
  • For private repositories, the github account belonging to the personal access token should atleast have read access to the private repo.

Output

  • version indicates the installed version of the specified package in the repo in the corresponding row. In case specified package isn't found, this value will be 0.0.1 and the script will install the package (this was improvised and can be changed easily).
  • version_satisfied indicates whether the installed version is greater than or equal to the specified version or not.
  • update_pr contains a link to a PR that updates the specified dependency to the specified version, if the -u flag was passed and the repo doesn't meet the requirements.

Sample Input/Outputs

Sample 1

Input

namerepo
dyte-react-sample-apphttps://github.com/dyte-in/react-sample-app/
dyte-js-sample-apphttps://github.com/dyte-in/javascript-sample-app
dyte-sample-app-backendhttps://github.com/dyte-in/backend-sample-app

Output without -u flag

namerepoversionversion_satisfied
dyte-react-sample-apphttps://github.com/dyte-in/react-sample-app/0.24.0true
dyte-js-sample-apphttps://github.com/dyte-in/javascript-sample-app0.21.1false
dyte-sample-app-backendhttps://github.com/dyte-in/backend-sample-app0.23.0true

Output with -u flag

namerepoversionversion_satisfiedupdate_pr
dyte-react-sample-apphttps://github.com/dyte-in/react-sample-app/0.24.0true
dyte-js-sample-apphttps://github.com/dyte-in/javascript-sample-app0.21.1falsehttps://github.com/dyte-in/javascript-sample-app/pull/3
dyte-sample-app-backendhttps://github.com/dyte-in/backend-sample-app0.23.0true

Sample 2

Input

namerepo
Netflix_-Clonehttps://github.com/ManuVairagi1/Netflix_-Clone
backendhttps://github.com/Aahaar007/backend
backendhttps://github.com/AndroAvi/backend

Output without -u flag

namerepoversionversion_satisfied
Netflix_-Clonehttps://github.com/ManuVairagi1/Netflix_-Clone0.22.0false
backendhttps://github.com/Aahaar007/backend0.21.0false
backendhttps://github.com/AndroAvi/backend0.0.1false

Output with -u flag

namerepoversionversion_satisfiedupdate_pr
Netflix_-Clonehttps://github.com/ManuVairagi1/Netflix_-Clone0.22.0falsehttps://github.com/ManuVairagi1/Netflix_-Clone/pull/34
backendhttps://github.com/Aahaar007/backend0.21.0falsehttps://github.com/Aahaar007/backend/pull/114
backendhttps://github.com/AndroAvi/backend0.0.1falsehttps://github.com/AndroAvi/backend/pull/9

A sample file has been added to the root directory for testing the script on 3 public repos. For testing on private repo's please provide your own.

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

License

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

Contact

Your Name - avijeetpandey87@gmail.com

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