Skip to content

Commit

Permalink
merged branch next
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Jul 15, 2023
2 parents c32e341 + 49951c1 commit bdcf3ff
Show file tree
Hide file tree
Showing 205 changed files with 1,841 additions and 11,880 deletions.
27 changes: 27 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,33 @@
"contributions": [
"code"
]
},
{
"login": "gorbunovav",
"name": "Andrey Gorbunov",
"avatar_url": "https://avatars.githubusercontent.com/u/2665015?v=4",
"profile": "https://github.com/gorbunovav",
"contributions": [
"code"
]
},
{
"login": "Tomasz-Silpion",
"name": "Tomasz Gregorczyk",
"avatar_url": "https://avatars.githubusercontent.com/u/5328659?v=4",
"profile": "https://github.com/Tomasz-Silpion",
"contributions": [
"code"
]
},
{
"login": "Judx",
"name": "Juho Hölsä",
"avatar_url": "https://avatars.githubusercontent.com/u/15036353?v=4",
"profile": "https://juhoholsa.com/",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7
Expand Down
45 changes: 45 additions & 0 deletions .ddev/commands/web/openmage-admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

## ProjectTypes: magento
## Description: Create/Update OpenMage Administrator Account
## Usage: openmage-admin
## Example: ddev openmage-admin

read -r -p "Choose your action for the administrator account [Create/Update]: " ACTION
ACTION=${ACTION,,} # to lower

if [[ "${ACTION}" =~ ^(update|u) || "${ACTION}" =~ ^(create|c) ]]; then
read -r -p "Admin User [admin]: " ADMIN_USER
ADMIN_USER=${ADMIN_USER:-admin}
read -r -p "Admin Firstname [OpenMage]: " ADMIN_FIRSTNAME
ADMIN_FIRSTNAME=${ADMIN_FIRSTNAME:-OpenMage}
read -r -p "Admin Lastname [Administrator]: " ADMIN_LASTNAME
ADMIN_LASTNAME=${ADMIN_LASTNAME:-Administrator}
read -r -p "Admin Email [admin@example.com]: " ADMIN_EMAIL
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com}
read -r -p "Admin Password [veryl0ngpassw0rd]: " ADMIN_PASSWORD
ADMIN_PASSWORD=${ADMIN_PASSWORD:-veryl0ngpassw0rd}
read -r -p "Table Prefix []: " TABLE_PREFIX
TABLE_PREFIX=${TABLE_PREFIX:-}
else
echo "Please run again and choose an action."
exit 1
fi

RANDOM_STRING=$({ tr -dc A-Za-z0-9 </dev/urandom | head -c 32 ; })

if [[ "${ACTION}" =~ ^(update|u) ]]; then
if mysql -u db -h db db -e "UPDATE "${TABLE_PREFIX}"admin_user SET password=CONCAT(MD5('"${RANDOM_STRING}""${ADMIN_PASSWORD}"'),':"${RANDOM_STRING}"') WHERE username='"${ADMIN_USER}"'"; then
echo "If the account "${ADMIN_USER}" exists it has been updated."
else
exit 1
fi
elif [[ "${ACTION}" =~ ^(create|c) ]]; then
if mysql -u db -h db db -e "INSERT INTO "${TABLE_PREFIX}"admin_user (firstname, lastname, email, username, password) VALUES ('"${ADMIN_FIRSTNAME}"', '"${ADMIN_LASTNAME}"', '"${ADMIN_EMAIL}"', '"${ADMIN_USER}"', CONCAT(MD5('"${RANDOM_STRING}""${ADMIN_PASSWORD}"'), ':"${RANDOM_STRING}"'))"; then
mysql -u db -h db db -e "INSERT INTO "${TABLE_PREFIX}"admin_role(parent_id, tree_level, sort_order, role_type, user_id, role_name)
VALUES (1, 2, 0, 'U',(SELECT user_id FROM "${TABLE_PREFIX}"admin_user WHERE username = '"${ADMIN_USER}"'),'"${ADMIN_FIRSTNAME}"')"
echo "The account "$ADMIN_USER" has been created."
else
exit 1
fi
fi
154 changes: 154 additions & 0 deletions .ddev/commands/web/openmage-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#!/bin/bash

## ProjectTypes: magento
## Description: Install OpenMage
## Usage: openmage-install [-d|--default] [-s|--sampledata] [-k|--keep] [-q|--quiet]
## Example: ddev openmage-install -d -s -k
## Flags: [{"Name":"default","Shorthand":"d","Usage":"use default values"},{"Name":"sampledata","Shorthand":"s","Usage":"install sample data"},{"Name":"keep","Shorthand":"k","Usage":"keep sample data package"},{"Name":"quiet","Shorthand":"q","Usage":"silent install with sample data"}]

ROOT="${PWD}"

QUIET_INSTALL_FLAG=''
SAMPLE_DATA_FLAG=''
SAMPLE_DATA_KEEP_FLAG=''
USE_DEFAULT_FLAG=''

while :; do
case ${1:-} in
-d|--default)
USE_DEFAULT_FLAG='true' ;;
-s|--sampledata)
SAMPLE_DATA_FLAG='true' ;;
-k|--keep)
SAMPLE_DATA_KEEP_FLAG='true' ;;
-q|--quiet)
QUIET_INSTALL_FLAG='true'
USE_DEFAULT_FLAG='true'
SAMPLE_DATA_FLAG='true'
;;
--) # End of all options.
shift
break
;;
-?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
;;
*) # Default case: No more options, so break out of the loop.
break
esac

shift
done

LOCALXML="${ROOT}/app/etc/local.xml"
if [ -f "${LOCALXML}" ]; then
if [[ "${QUIET_INSTALL_FLAG}" ]]; then
DELETE='y'
else
read -r -p "OpenMage is already installed. Delete local.xml and drop the database? [y/N] " DELETE
DELETE=${DELETE,,} # to lower
fi

if [[ "${DELETE}" =~ ^(yes|y) ]]; then
mysql -u db -h db -e "DROP SCHEMA IF EXISTS db; CREATE SCHEMA db;";
rm "${LOCALXML}"
else
exit 1
fi
fi

# install sample data
if [[ "${SAMPLE_DATA_FLAG}" ]]; then
INSTALL_SAMPLE_DATA='y'
else
read -r -p "Install Sample Data? [y/N] " INSTALL_SAMPLE_DATA
INSTALL_SAMPLE_DATA=${INSTALL_SAMPLE_DATA,,} # to lower
fi

if [[ $INSTALL_SAMPLE_DATA =~ ^(yes|y) ]]; then
SAMPLE_DATA_URL=https://github.com/Vinai/compressed-magento-sample-data/raw/master/compressed-magento-sample-data-1.9.2.4.tgz
SAMPLE_DATA_DIRECTORY="${ROOT}/.sampleData"
SAMPLE_DATA_FILE=sample_data.tgz

if [[ ! -d "${SAMPLE_DATA_DIRECTORY}" ]]; then
echo "Creating Sample Data directory..."
mkdir -p "${SAMPLE_DATA_DIRECTORY}"
fi

cd "${SAMPLE_DATA_DIRECTORY}" || exit
if [[ ! -f "${SAMPLE_DATA_DIRECTORY}/${SAMPLE_DATA_FILE}" ]]; then
echo "Downloading Sample Data..."
wget "${SAMPLE_DATA_URL}" -O "${SAMPLE_DATA_FILE}"
fi

echo "Uncompressing Sample Data..."
tar xf "${SAMPLE_DATA_FILE}"

echo "Copying Sample Data into the OpenMage directory..."
cp -r magento-sample-data-1.9.2.4/* "${ROOT}/"

echo "Importing Sample Data into the database..."
mysql -u db -h db db < "${SAMPLE_DATA_DIRECTORY}/magento-sample-data-1.9.2.4/magento_sample_data_for_1.9.2.4.sql"

# remove sample data
if [[ "${SAMPLE_DATA_KEEP_FLAG}" ]]; then
rm -rf $(
find . -maxdepth 1 -type f -name "*" ! -name "${SAMPLE_DATA_FILE}")
else
cd "${ROOT}" || exit
rm -rf "${SAMPLE_DATA_DIRECTORY}"
fi
fi

cd "${ROOT}" || exit

if [[ "${USE_DEFAULT_FLAG}" ]]; then
ADMIN_USER='admin'
ADMIN_FIRSTNAME='OpenMage'
ADMIN_LASTNAME='Administrator'
ADMIN_EMAIL='admin@example.com'
ADMIN_PASSWORD='veryl0ngpassw0rd'
TABLE_PREFIX='om_'
else
read -r -p "Admin User [admin]: " ADMIN_USER
ADMIN_USER=${ADMIN_USER:-admin}
read -r -p "Admin Firstname [OpenMage]: " ADMIN_FIRSTNAME
ADMIN_FIRSTNAME=${ADMIN_FIRSTNAME:-OpenMage}
read -r -p "Admin Lastname [Administrator]: " ADMIN_LASTNAME
ADMIN_LASTNAME=${ADMIN_LASTNAME:-Administrator}
read -r -p "Admin Email [admin@example.com]: " ADMIN_EMAIL
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com}
read -r -p "Admin Password [veryl0ngpassw0rd]: " ADMIN_PASSWORD
ADMIN_PASSWORD=${ADMIN_PASSWORD:-veryl0ngpassw0rd}
if [[ $INSTALL_SAMPLE_DATA =~ ^(yes|y) ]]; then
TABLE_PREFIX=''
else
read -r -e -i 'om_' -p "Table Prefix [om_]: " TABLE_PREFIX
fi
fi

php -f install.php -- \
--license_agreement_accepted 'yes' \
--locale 'en_US' \
--timezone 'America/New_York' \
--db_host 'db' \
--db_name 'db' \
--db_user 'db' \
--db_pass 'db' \
--db_prefix "${TABLE_PREFIX}" \
--url "${DDEV_PRIMARY_URL}" \
--use_rewrites 'yes' \
--use_secure 'yes' \
--secure_base_url "${DDEV_PRIMARY_URL}" \
--use_secure_admin 'yes' \
--admin_username "${ADMIN_USER}" \
--admin_lastname "${ADMIN_LASTNAME}" \
--admin_firstname "${ADMIN_FIRSTNAME}" \
--admin_email "${ADMIN_EMAIL}" \
--admin_password "${ADMIN_PASSWORD}" \
--session_save 'files' \
--admin_frontname 'admin' \
--backend_frontname 'admin' \
--default_currency 'USD' \
--enable_charts 'yes' \
--skip_url_validation 'yes'
37 changes: 37 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Make packagist / composer download smaller
/.ddev export-ignore
/.github export-ignore
/dev export-ignore
/docs export-ignore

/.all-contributorsrc export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.gitpod.yml export-ignore

/.php-cs-fixer.dist.php export-ignore
/.phpcs.ecg.xml.dist export-ignore
/.phpcs.php.xml.dist export-ignore
/.phpcs.xml.dist export-ignore
/.phpmd.dist.xml export-ignore
/phpstan.dist.baseline.neon export-ignore
/phpstan.dist.issues.neon export-ignore
/phpstan.dist.neon export-ignore

/README.md export-ignore

# Enforce checkout with linux lf consistent over all platforms
*.html text eol=lf
*.css text eol=lf
*.js text eol=lf
*.json text eol=lf
*.php text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.xml text eol=lf
*.sh text eol=lf
*.sql text eol=lf
*.svg text eol=lf
*.txt text eol=lf
*.phtml text eol=lf
64 changes: 50 additions & 14 deletions .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ jobs:
name: Changed
runs-on: [ubuntu-latest]
outputs:
composer: ${{ steps.all.outputs.composer }}
php: ${{ steps.all.outputs.php }}
xml: ${{ steps.all.outputs.xml }}
workflow: ${{ steps.all.outputs.workflow }}
phpcs: ${{ steps.all.outputs.phpcs }}
php-cs-fixer: ${{ steps.all.outputs.php-cs-fixer }}
phpstan: ${{ steps.all.outputs.phpstan }}
phpunit-test: ${{ steps.all.outputs.phpunit-test }}
phpunit: ${{ steps.all.outputs.phpunit }}
sonar: ${{ steps.all.outputs.sonar }}
composer: ${{ steps.changes-composer.outputs.composer }}
php: ${{ steps.changes-php.outputs.php }}
xml: ${{ steps.changes-xml.outputs.xml }}
workflow: ${{ steps.changes-workflow.outputs.workflow }}
phpcs: ${{ steps.changes-phpcs.outputs.phpcs }}
php-cs-fixer: ${{ steps.changes-php-cs-fixer.outputs.php-cs-fixer }}
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
sonar: ${{ steps.changes-sonar.outputs.sonar }}

steps:
- name: Checkout code
Expand All @@ -71,7 +71,7 @@ jobs:

- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v35
uses: tj-actions/changed-files@v37
with:
files: |
composer.*
Expand All @@ -86,8 +86,8 @@ jobs:
dev/phpunit*
dev/sonar*
- name: Run step if any file(s) changed
id: all
- name: Check if composer files changed
id: changes-composer
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
echo "One or more files have changed."
Expand All @@ -96,38 +96,74 @@ jobs:
echo "$count Composer file(s) changed"
echo "composer=$count" >> $GITHUB_OUTPUT
- name: Check if PHP files changed
id: changes-php
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "*.php" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHP file(s) changed"
echo "php=$count" >> $GITHUB_OUTPUT
- name: Check if XML files changed
id: changes-xml
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "*.xml" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count XML file(s) changed"
echo "xml=$count" >> $GITHUB_OUTPUT
- name: Check if Workflow files changed
id: changes-workflow
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE ".github/workflows/**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count Workflow file(s) changed"
echo "workflow=$count" >> $GITHUB_OUTPUT
- name: Check if PHPCS test files changed
id: changes-phpcs
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**phpcs**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPCS file(s) changed"
echo "phpcs=$count" >> $GITHUB_OUTPUT
- name: Check if PHP-CS-Fixer files changed
id: changes-php-cs-fixer
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**php-cs-fixer**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHP-CS-Fixer file(s) changed"
echo "php-cs-fixer=$count" >> $GITHUB_OUTPUT
- name: Check if PHPStan files changed
id: changes-phpstan
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**phpstan**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPStan file(s) changed"
echo "phpstan=$count" >> $GITHUB_OUTPUT
- name: Check if PHPUnit test files changed
id: changes-phpunit-test
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "dev/tests/" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count UnitTest test file(s) changed"
echo "phpunit-test=$count" >> $GITHUB_OUTPUT
- name: Check if PHPUnit files changed
id: changes-phpunit
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "dev/phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count UnitTest file(s) changed"
echo "$count PHPUnit file(s) changed"
echo "phpunit=$count" >> $GITHUB_OUTPUT
- name: Check if Sonar files changed
id: changes-sonar
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "dev/sonar*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count Sonar file(s) changed"
echo "sonar=$count" >> $GITHUB_OUTPUT
Loading

0 comments on commit bdcf3ff

Please sign in to comment.