mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 05:31:24 +00:00
Devenv subcommands for test / format (#462)
* Add devenv subcommands for test / format * Rename dev-env-config to devenvconfig for consitency sake
This commit is contained in:
committed by
GitHub
parent
770da45dbf
commit
78dfdbe162
@@ -21,6 +21,7 @@ tests/
|
|||||||
vendor/
|
vendor/
|
||||||
|
|
||||||
.dockerignore
|
.dockerignore
|
||||||
|
.devenvconfig
|
||||||
.editorconfig
|
.editorconfig
|
||||||
.env
|
.env
|
||||||
.env.testing
|
.env.testing
|
||||||
@@ -28,7 +29,6 @@ vendor/
|
|||||||
.gitattributes
|
.gitattributes
|
||||||
.gitignore
|
.gitignore
|
||||||
.prettierrc.json
|
.prettierrc.json
|
||||||
.dev-env-config
|
|
||||||
devenv
|
devenv
|
||||||
|
|
||||||
CODE_OF_CONDUCT.md
|
CODE_OF_CONDUCT.md
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -21,7 +21,7 @@ Homestead.yaml
|
|||||||
!storage/fonts/.gitkeep
|
!storage/fonts/.gitkeep
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.php-cs-fixer.cache
|
.php-cs-fixer.cache
|
||||||
.dev-env-config
|
.devenvconfig
|
||||||
/storage/fonts*
|
/storage/fonts*
|
||||||
package-lock.json
|
package-lock.json
|
||||||
/docker/development/docker-compose.yml
|
/docker/development/docker-compose.yml
|
||||||
|
|||||||
46
devenv
46
devenv
@@ -42,6 +42,8 @@ show_usage() {
|
|||||||
echo " rebuild Rebuild and restart the development environment"
|
echo " rebuild Rebuild and restart the development environment"
|
||||||
echo " shell Enter the PHP container's shell"
|
echo " shell Enter the PHP container's shell"
|
||||||
echo " run [CMD] Run a command inside the PHP container (e.g., ./artisan)"
|
echo " run [CMD] Run a command inside the PHP container (e.g., ./artisan)"
|
||||||
|
echo " test Run the test suite (Pest)"
|
||||||
|
echo " format Format the code (Pint)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Examples:"
|
echo "Examples:"
|
||||||
echo " $0 # Interactive setup and start"
|
echo " $0 # Interactive setup and start"
|
||||||
@@ -72,7 +74,7 @@ get_docker_compose_cmd() {
|
|||||||
|
|
||||||
# Function to find the most recent compose file used
|
# Function to find the most recent compose file used
|
||||||
find_compose_file() {
|
find_compose_file() {
|
||||||
local config_file=".dev-env-config"
|
local config_file=".devenvconfig"
|
||||||
|
|
||||||
if [ -f "$config_file" ]; then
|
if [ -f "$config_file" ]; then
|
||||||
cat "$config_file"
|
cat "$config_file"
|
||||||
@@ -84,7 +86,7 @@ find_compose_file() {
|
|||||||
# Function to save compose file configuration
|
# Function to save compose file configuration
|
||||||
save_config() {
|
save_config() {
|
||||||
local compose_file=$1
|
local compose_file=$1
|
||||||
echo "$compose_file" > .dev-env-config
|
echo "$compose_file" > .devenvconfig
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to check if host entry exists
|
# Function to check if host entry exists
|
||||||
@@ -333,7 +335,7 @@ cmd_destroy() {
|
|||||||
if $docker_compose -f "$compose_file" down --rmi all --volumes --remove-orphans; then
|
if $docker_compose -f "$compose_file" down --rmi all --volumes --remove-orphans; then
|
||||||
print_success "Development environment destroyed successfully!"
|
print_success "Development environment destroyed successfully!"
|
||||||
# Remove the config file since everything is destroyed
|
# Remove the config file since everything is destroyed
|
||||||
rm -f .dev-env-config
|
rm -f .devenvconfig
|
||||||
else
|
else
|
||||||
print_error "Failed to destroy development environment"
|
print_error "Failed to destroy development environment"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -427,6 +429,36 @@ cmd_run() {
|
|||||||
docker exec -it -w /var/www/html invoiceshelf-dev-php "$@"
|
docker exec -it -w /var/www/html invoiceshelf-dev-php "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to run tests
|
||||||
|
cmd_test() {
|
||||||
|
print_info "Running tests (Pest)..."
|
||||||
|
|
||||||
|
# Check if the container is running first
|
||||||
|
if ! docker ps --format "{{.Names}}" | grep -q "invoiceshelf-dev-php"; then
|
||||||
|
print_error "PHP container 'invoiceshelf-dev-php' is not running."
|
||||||
|
print_info "Start the development environment first with: $0 start"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift # Remove 'test' from arguments
|
||||||
|
docker exec -it -w /var/www/html invoiceshelf-dev-php /var/www/html/vendor/bin/pest "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to format code
|
||||||
|
cmd_format() {
|
||||||
|
print_info "Formatting code (Pint)..."
|
||||||
|
|
||||||
|
# Check if the container is running first
|
||||||
|
if ! docker ps --format "{{.Names}}" | grep -q "invoiceshelf-dev-php"; then
|
||||||
|
print_error "PHP container 'invoiceshelf-dev-php' is not running."
|
||||||
|
print_info "Start the development environment first with: $0 start"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift # Remove 'format' from arguments
|
||||||
|
docker exec -it -w /var/www/html invoiceshelf-dev-php /var/www/html/vendor/bin/pint "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to show service information
|
# Function to show service information
|
||||||
show_service_info() {
|
show_service_info() {
|
||||||
echo ""
|
echo ""
|
||||||
@@ -537,6 +569,14 @@ main() {
|
|||||||
validate_environment > /dev/null
|
validate_environment > /dev/null
|
||||||
cmd_run "$@"
|
cmd_run "$@"
|
||||||
;;
|
;;
|
||||||
|
"test")
|
||||||
|
validate_environment > /dev/null
|
||||||
|
cmd_test "$@"
|
||||||
|
;;
|
||||||
|
"format")
|
||||||
|
validate_environment > /dev/null
|
||||||
|
cmd_format "$@"
|
||||||
|
;;
|
||||||
"help"|"-h"|"--help")
|
"help"|"-h"|"--help")
|
||||||
show_usage
|
show_usage
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user