@eggsy001/npm-verify v0.0.5
About The Project
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
git
node.js (recommended v16.5.0 LTS)
npm
npm i -g npm
or
npm install npm@latest -g
Installation
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.
- repo
Clone the repo
git clone https://github.com/dyte-submissions/dyte-vit-2022-AndroAvi.git
- Install NPM packages
npm install
- Make installed package globally available
npm link
- Alternatively, skip steps 2-4 and
to install the published npm package directly.npm install -g @eggsy001/npm-verify
- Verify installation
Should return the following output:npm-verify --help
Usage
Checking the dependency versions
- 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, orcd "PATH" #path is the path from cwd to input file.
- run
npm-verify -i "INPUT_FILE_NAME.csv" -t "GITHUB_PERSONAL ACCESS_TOKEN" "PACKAGE_NAME"@"PACKAGE_VERSION"
- Wait for the finish message. The output file
output.csv
would now be created in the cwd.
Creating update PR for version mismatches
- Again, make sure that the input file is in the cwd.
- run:
npm-verify -i "INPUT_FILE_NAME.csv" -t "GITHUB_PERSONAL ACCESS_TOKEN" "PACKAGE_NAME"@"PACKAGE_VERSION" -u
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
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 secondrepo
. - The
name
column contains the name of the repo. - The
repo
column should contain a standard github repo link of the formathttps://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 be0.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
name | repo |
---|---|
dyte-react-sample-app | https://github.com/dyte-in/react-sample-app/ |
dyte-js-sample-app | https://github.com/dyte-in/javascript-sample-app |
dyte-sample-app-backend | https://github.com/dyte-in/backend-sample-app |
Output without -u
flag
name | repo | version | version_satisfied |
---|---|---|---|
dyte-react-sample-app | https://github.com/dyte-in/react-sample-app/ | 0.24.0 | true |
dyte-js-sample-app | https://github.com/dyte-in/javascript-sample-app | 0.21.1 | false |
dyte-sample-app-backend | https://github.com/dyte-in/backend-sample-app | 0.23.0 | true |
Output with -u
flag
name | repo | version | version_satisfied | update_pr |
---|---|---|---|---|
dyte-react-sample-app | https://github.com/dyte-in/react-sample-app/ | 0.24.0 | true | |
dyte-js-sample-app | https://github.com/dyte-in/javascript-sample-app | 0.21.1 | false | https://github.com/dyte-in/javascript-sample-app/pull/3 |
dyte-sample-app-backend | https://github.com/dyte-in/backend-sample-app | 0.23.0 | true |
Sample 2
Input
name | repo |
---|---|
Netflix_-Clone | https://github.com/ManuVairagi1/Netflix_-Clone |
backend | https://github.com/Aahaar007/backend |
backend | https://github.com/AndroAvi/backend |
Output without -u
flag
name | repo | version | version_satisfied |
---|---|---|---|
Netflix_-Clone | https://github.com/ManuVairagi1/Netflix_-Clone | 0.22.0 | false |
backend | https://github.com/Aahaar007/backend | 0.21.0 | false |
backend | https://github.com/AndroAvi/backend | 0.0.1 | false |
Output with -u
flag
name | repo | version | version_satisfied | update_pr |
---|---|---|---|---|
Netflix_-Clone | https://github.com/ManuVairagi1/Netflix_-Clone | 0.22.0 | false | https://github.com/ManuVairagi1/Netflix_-Clone/pull/34 |
backend | https://github.com/Aahaar007/backend | 0.21.0 | false | https://github.com/Aahaar007/backend/pull/114 |
backend | https://github.com/AndroAvi/backend | 0.0.1 | false | https://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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - 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