cypress
cypress copied to clipboard
Allow Configuration Of Which Env Routes Should Not Publish For
The Problem
I am not able to adjust the added cypress routes based on environment (expect Production). When my APP_ENV
is set to local
or something like ci
that is fine to have those routes added, but some workflows have several testing and qa environments where these routes might not be appropriate for.
What Exist Now
Currently, as defined in the CypressServiceProvider
only when in the parent application (i.e. the app using the package) has its application environment APP_ENV
set to production
do the added Cypress routes not get published. To confirm this, you can change in your app:
APP_ENV=production
Then run php artisan route:list | grep cypress
to see no results.
Alternatively you can have that set to local, or any other value and see a list of added cypress routes.
Solution
Within this PR I have added a feature that will now check if the application has a config/cypress.php
file and if any application environment names are listed in the exclude
key, they will be treated similar to how production environment works now, and they will not be added.
This also makes sure that the production environment is always added regardless of config,
Examples
Here I have an app which its .env
& config/cypress.php
look like the following:
.env
APP_ENV=staging
config/cypress.php
<?php
'exclude' => 'production'
];
Small note, you would't need to add
production
here, just to simplify example.
Given the following example I would see the following routes added
Now if I update my config/cypress.php
to include the staging
environment too, then re-run command, I should not see the routes listed anymore.