Преглед изворни кода

`bin/init` script to initialize development environment with sample data and dev-related modules (#1377)

Co-authored-by: Aimane Couissi <contact@aimanecouissi.com>
Co-authored-by: Mark Shust <mark@shust.com>
Aimane Couissi пре 1 недеља
родитељ
комит
cbcfd97d2d
3 измењених фајлова са 38 додато и 4 уклоњено
  1. 7 4
      README.md
  2. 1 0
      compose/Makefile
  3. 30 0
      compose/bin/init

+ 7 - 4
README.md

@@ -158,13 +158,12 @@ The `magento.test` above defines the hostname to use, `community` is the Magento
 
 
 After the one-liner above completes running, you should be able to access your site at `https://magento.test`.
 After the one-liner above completes running, you should be able to access your site at `https://magento.test`.
 
 
-#### Install sample data
+#### Install sample data and development modules
 
 
-After the above installation is complete, run the following lines to install sample data:
+After the above installation is complete, you can initialize the development environment with sample data and dev-related modules with:
 
 
 ```bash
 ```bash
-bin/magento sampledata:deploy
-bin/magento setup:upgrade
+bin/init
 ```
 ```
 
 
 ### Manual Setup
 ### Manual Setup
@@ -197,6 +196,9 @@ bin/download community 2.4.8-p3
 # Run the setup installer for Magento:
 # Run the setup installer for Magento:
 bin/setup magento.test
 bin/setup magento.test
 
 
+# Initialize development environment with sample data and dev-related modules:
+bin/init
+
 open https://magento.test
 open https://magento.test
 ```
 ```
 
 
@@ -302,6 +304,7 @@ It is recommended to keep your root docker config files in one repository, and y
 - `bin/fixowns`: This will fix filesystem ownerships within the container.
 - `bin/fixowns`: This will fix filesystem ownerships within the container.
 - `bin/fixperms`: This will fix filesystem permissions within the container.
 - `bin/fixperms`: This will fix filesystem permissions within the container.
 - `bin/grunt`: Run the grunt binary. Ex. `bin/grunt exec`
 - `bin/grunt`: Run the grunt binary. Ex. `bin/grunt exec`
+- `bin/init`: Initialize development environment with sample data and dev-related modules.
 - `bin/install-php-extensions`: Install PHP extension in the container. Ex. `bin/install-php-extensions sourceguardian`
 - `bin/install-php-extensions`: Install PHP extension in the container. Ex. `bin/install-php-extensions sourceguardian`
 - `bin/log`: Monitor the Magento log files. Pass no params to tail all files. Ex. `bin/log debug.log`
 - `bin/log`: Monitor the Magento log files. Pass no params to tail all files. Ex. `bin/log debug.log`
 - `bin/magento`: Run the Magento CLI. Ex: `bin/magento cache:flush`
 - `bin/magento`: Run the Magento CLI. Ex: `bin/magento cache:flush`

+ 1 - 0
compose/Makefile

@@ -46,6 +46,7 @@ help:
 	@echo "$(call format,fixowns,'This will fix filesystem ownerships within the container.')"
 	@echo "$(call format,fixowns,'This will fix filesystem ownerships within the container.')"
 	@echo "$(call format,fixperms,'This will fix filesystem permissions within the container.')"
 	@echo "$(call format,fixperms,'This will fix filesystem permissions within the container.')"
 	@echo "$(call format,grunt,'Run the grunt binary.')"
 	@echo "$(call format,grunt,'Run the grunt binary.')"
+	@echo "$(call format,init,'Initialize development environment with sample data and dev-related modules.')"
 	@echo "$(call format,install-php-extensions,'Install PHP extension in the container.')"
 	@echo "$(call format,install-php-extensions,'Install PHP extension in the container.')"
 	@echo "$(call format,log,'Monitor the Magento log files. Pass no params to tail all files.')"
 	@echo "$(call format,log,'Monitor the Magento log files. Pass no params to tail all files.')"
 	@echo "$(call format,magento,'Run the Magento CLI.')"
 	@echo "$(call format,magento,'Run the Magento CLI.')"

+ 30 - 0
compose/bin/init

@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Script to initialize a Magento development environment
+
+# Exit immediately if a command fails
+set -e
+
+echo ">>> Deploying Magento sample data..."
+bin/magento sampledata:deploy
+
+echo ">>> Disabling Two-Factor Authentication (for dev only)..."
+bin/composer require --dev markshust/magento2-module-disabletwofactorauth
+bin/magento module:enable MarkShust_DisableTwoFactorAuth
+
+echo ">>> Running setup upgrade (applies sample data + new modules)..."
+bin/magento setup:upgrade
+
+echo ">>> Setting long admin session lifetime (1 year)..."
+bin/magento config:set twofactorauth/general/enable 0
+bin/magento config:set admin/security/session_lifetime 31536000
+
+echo ">>> Generating URN catalog for IDEs..."
+bin/dev-urn-catalog-generate
+
+echo ">>> Running final optimizations (compile, reindex, cache flush)..."
+bin/magento setup:di:compile
+bin/magento indexer:reindex
+bin/magento cache:flush
+
+echo ">>> Magento development environment initialized successfully! 🎉"