Add collection level tests and pre-request scripts automatically


I am generating a new collection based on the swagger specification.
Next, I want to automatically add collection level scripts and tests to this collection.
Is there such an opportunity through NPM libraries?

Ideally, any updates in the swagger should trigger the creation of a new collection, which will be automatically checked.
I did not find any options to store tests outside the *.json collection. It is impossible to refer to external tests through any option.