Skip to content

Commit

Permalink
V3 (#28)
Browse files Browse the repository at this point in the history
* Added v3

* Removed old files

* test

* renamed test files

* Added git message

* Added git message

* Added coverage

* Updated gitignore

* Update file path

* Update file path

* Updated snap

* Updated Example text

* Updated readme

* Added variable aggregation

* Added variable aggregation

* Added variable aggregation
  • Loading branch information
praveendvd authored Feb 3, 2022
1 parent 99e6fa4 commit c3bfef0
Show file tree
Hide file tree
Showing 28 changed files with 2,691 additions and 572 deletions.
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
node_modules
package-lock.json
__test__/collection/output
__test__/collection/new_collection.json
__test__/*copy*
coverage
new_collection.json
*.tgz

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ Added main entry point to the package to allow to be used as a dependency
Added error handling for invalid source collection

### Fixed

## [3.0.0] - 2022-02-03

### Added

Added ability to move multiple collection into single collection

### Fixed
113 changes: 106 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,80 @@


![logo](https://github.com/praveendvd/postman_collection_url_updater/raw/master/logo/logo.png)

Github page: https://praveendvd.github.io/postman_collection_url_updater/

# postman-collection-url-updater
- [Introduction](#introduction)
- [Getting started](#getting-started)
- [Executing the utilities](#executing-the-utilities)
+ [postman-collection-url-updater:](#postman-collection-url-updater-)
+ [postman-collection-aggregator:](#postman-collection-aggregator-)
- [Utitlity Specific Documentation](#utitlity-specific-documentation)
* [postman-collection-url-updater](#postman-collection-url-updater)
+ [in case of PATH and Query variables:](#in-case-of-path-and-query-variables-)
+ [in case of REGEx match:](#in-case-of-regex-match-)
+ [Interactive Option](#interactive-option)
+ [CLI Options](#cli-options)
* [postman-collection-aggregator](#postman-collection-aggregator)
+ [Interactive Option](#interactive-option-1)
+ [CLI Options](#cli-options-1)


# Introduction

Postman collection url updater is a command line utility project that can update urls across multiple postman requests in your postman collection and, move multiple collections into single collection. It allows to **update postman request urls in bulk inside the postman collection**, and also support **migrating multiple collection into single collection**",❤️

To use the project , just install the package and then run any of the below commandline utilities as per your need 🎉🎉

1. **postman-collection-url-updater :** A commandline utilty that allows to update urls in bulk inside your collection
2. **postman-collection-aggregator :** A commandline utilty that allows to move all collections into a single collection

# Getting started

First install the package locally or globally

`npm i postman-collection-url-updater`

or

`npm i -g postman-collection-url-updater`


# Executing the utilities

Now the utility can be executed as directly or using npx, depending whether the package was installed globally or
locally

### postman-collection-url-updater:

**if installed locally:**

`npx postman-collection-url-updater -c collection.json -r www.test.com -w {{Baseurl}}`

**if installed globally:**

`postman-collection-url-updater -c collection.json -r www.test.com -w {{Baseurl}}`

### postman-collection-aggregator:

**if installed locally:**

`npx postman-collection-aggregator -d collectiondirectory -n Aggregated_collection`

Postman collection url updater (postman-collection-url-updater) is a command line utility project that can update urls across multiple postman requests in your postman collection. It allows to update postman request urls in bulk inside the postman collection
**if installed globally:**

`postman-collection-aggregator -d collectiondirectory -n Aggregated_collection`

# Utitlity Specific Documentation

## postman-collection-url-updater

postman-collection-url-updater is a command line utility project that can update urls across multiple postman requests in your postman collection. It allows to update postman request urls in bulk inside the postman collection

for instance, let say your Postman request URLs where in the form https://localhost:23456/api/v1/{{path}} and you wanted modify all the requests inside your postman collection as {{baseURL}}/{{path}} you can do it as:

npx postman-collection-url-updater -c "collection.json" -r "https://localhost:23456/api/v1/{{path}}" -w "{{baseURL}}/{{path}}" -s "new_collection.json"

## in case of PATH and Query variables:
### in case of PATH and Query variables:

npx postman-collection-url-updater -c "collection.json" -r "https://{{test}}/:test/test" -w "https://localhost/newpath/:test/:test2""

Expand All @@ -28,7 +90,7 @@ makes the changes and removes :test if it doesn't exists in remaining part and r

eg , output would be https://localhost/newpath/:test/new , if path variable exists else https://localhost/newpath/new

## in case of REGEx match:
### in case of REGEx match:

Pass the regex as -r parameter and replace it with -w parameter. -w parameter will have the capture group available:

Expand All @@ -45,14 +107,15 @@ This will replace all urls having query parameter to the form \<path\>?newquery
If you want to add query parameter to all URLs irrespective of whether the query parameter exists or not, then use :

npx postman-collection-url-updater -c "collection.json" -r "^(.*?)(?:\?(.*))?$" -w "$1?newquery=newvalue&$2" -p true
## Interactive Option

### Interactive Option

You can also pass arguments interactively by passing i flag

`npx postman-collection-url-updater -i`


## CLI Options
### CLI Options


| options | alias | description | Example |
Expand All @@ -64,3 +127,39 @@ You can also pass arguments interactively by passing i flag
| --with_url_part| -w| The value to replace the matching URL part with| v2 or {{baseURL}}/{{path}} or localhost:8888/| |
| --save_as| -s | (Optional) Path to output collection file, DEFAULT: new_collection.json. If no value provided then the file will be saved by prefixing new to current collection name | modifiedCollection.json or project/modifiedCollection.json|

## postman-collection-aggregator

postman-collection-aggregator is a command line utility project that can move multiple collections into a new single collection. For instance , lets say you have two collections A and B , **then a new collection C will be created with A and B as folders in C**. As folders doesn't support variables , **collection variable will be added to the parent collections variables section and duplicate variables might be merged** all other properties remains intact

You can either pass in the directory containing all the collection.json files that you want to aggregate using -d argument or pass path to each individual target collections using -l argument

`postman-collection-aggregator -d ./collectionFolder` or

postman-collection-aggregator -l "./collectionFolder/collection1.json" "./collectionFolder/collection2.json"

you can pass name of your new collection using -n

`postman-collection-aggregator -d ./collectionFolder -n "new_collection"`

**see more arguments in the below sections**

### Interactive Option

You can also pass arguments interactively by passing i flag

`postman-collection-aggregator -i`


### CLI Options


| options | alias | description | Example |
|--|--|-- |--|
| --interactive| -i | (Optional) Allows to pass arguments interactively, DEFAULT: false.| `npx postman-collection-aggregator -i` |
| --new_collection_name| -n | (Optional) Pass name for your new collection, DEFAULT: Aggregated_collection|
| --collection_list | -l | Path to the each individual target Collection.json file separated by space|`npx postman-collection-aggregator -l "./collection1.json" "./collection2.json" -n "new_collection"`
| --collection_directory| -d | Path to the directory containing all the collection.json files. [**NOTE**: only direct childs will be considered , subdirectories are ignored]|`npx postman-collection-aggregator -d "./collectionDirectory" -n "new_collection"`
| --save_as| -s | (Optional) Path to output collection file, DEFAULT: <collection_name>.collection.json.|`npx postman-collection-aggregator -d "./collectionDirectory" -n "new_collection" -s "output/new.json"`

**Note:** Either -d or -l is required . If both are given only -d will be considered

Loading

0 comments on commit c3bfef0

Please sign in to comment.