diff --git a/bin/component_parts/defaultview.sh b/bin/component_parts/defaultview.sh deleted file mode 100644 index 87f6748..0000000 --- a/bin/component_parts/defaultview.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Check if $name is set -if [[ -z "${name}" ]]; then - echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)." - exit 1 -fi - -cat < admin/tmpl/${name}/default.php - - -

Hello ${name}!

- -EOM diff --git a/bin/component_parts/displaycontroller.sh b/bin/component_parts/displaycontroller.sh deleted file mode 100644 index 9931236..0000000 --- a/bin/component_parts/displaycontroller.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Check if $name is set -if [[ -z "${name}" ]]; then - echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)." - exit 1 -fi - -cat < admin/src/Controller/DisplayController.php - admin/language/en-GB/en-GB.com_${name}.ini -; com_${name} -COM_${name^^}_DESCRIPTION="Placeholder description, edit in language file" -EOM - - \ No newline at end of file diff --git a/bin/component_parts/manifest.sh b/bin/component_parts/manifest.sh deleted file mode 100644 index 1c75270..0000000 --- a/bin/component_parts/manifest.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -current_date=$(date +'%B %Y') -current_year=$(date +'%Y') -# Check if JOOMLA_USER is set, otherwise prompt for it -if [ -z "$JOOMLA_USER" ]; then - read -p "Enter the Joomla user: " JOOMLA_USER -fi - -# Check if EMAIL is set, otherwise prompt for it -if [ -z "$EMAIL" ]; then - read -p "Enter the email address: " EMAIL -fi - -cat < ${name}.xml - - - ${name} - ${current_date} - ${JOOMLA_USER} - ${EMAIL} - https://www.example.com/ - Copyright (C) ${current_year} ${JOOMLA_USER}, All rights reserved. - GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - 0.0.1 - - - COM_${name^^}_DESCRIPTION - - Harvst\Component\\${name^} - - - - ${name^} - - language - services - src - tmpl - - - - language/en-GB/en-GB.com_${name}.ini - - - -EOM - - \ No newline at end of file diff --git a/bin/component_parts/provider.sh b/bin/component_parts/provider.sh deleted file mode 100644 index 41a78aa..0000000 --- a/bin/component_parts/provider.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -cat < admin/services/provider.php - -registerServiceProvider(new MVCFactory('\\\\Harvst\\\\Component\\\\${name^}')); - \$container->registerServiceProvider(new ComponentDispatcherFactory('\\\\Harvst\\\\Component\\\\${name^}')); - \$container->set( - ComponentInterface::class, - function (Container \$container) { - \$component = new MVCComponent(\$container->get(ComponentDispatcherFactoryInterface::class)); - \$component->setMVCFactory(\$container->get(MVCFactoryInterface::class)); - - return \$component; - } - ); - } -}; - -EOM diff --git a/bin/component_parts/view.sh b/bin/component_parts/view.sh deleted file mode 100644 index 6f2ab02..0000000 --- a/bin/component_parts/view.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Check if $name is set -if [[ -z "${name}" ]]; then - echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)." - exit 1 -fi - -cat < admin/src/View/${name^}/HtmlView.php -/dev/null 2>&1 && pwd)" - -################################################################################# -# ENV File -################################################################################# -# Import variables from .env file -if [ -f "$script_dir/../.env" ]; then - read -p "Found .env file at '$script_dir/.env'. Press Enter to use it, or enter a different file path: " env_file - if [ -z "$env_file" ]; then - env_file="$script_dir/.env" - fi -else - read -p "Enter the path to the .env file: " env_file -fi - -# Validate the .env file path -if [ ! -f "$env_file" ]; then - echo "Invalid .env file path. Please make sure the file exists." - exit 1 -fi - -# Source the variables from the .env file -source "$env_file" - -echo "Variables from .env file imported successfully!" - -################################################################################# -# Component Name -################################################################################# - -# Check if the component name is provided as the first parameter -if [ -n "$1" ]; then - name="$1" -else - # Prompt for the name of the component - read -p "Enter the name of the component (one word in lowercase): " name -fi - -# Validate the component name -if [[ ! "$name" =~ ^[a-z0-9_]+$ ]]; then - echo "Invalid component name. The name should be one word in lowercase with no spaces or special characters." - exit 1 -fi - -# Check if Components directory exists (development) -if [ ! -d "development" ]; then - echo "Development directory not found. Creating the directory..." - mkdir "development" -fi - -# Change the current working directory to Components -cd "development" || exit - -################################################################################# -# Do the work -################################################################################# - -# Create the component directory -component_dir="com_${name}" -mkdir -p "$component_dir" - -# Create the main component files -cd "$component_dir" || exit -mkdir -p site -mkdir -p admin/language/en-GB admin/services -mkdir -p admin/src/Controller admin/src/View/${name^} admin/tmpl/${name} - -# Source the files for generating component files -source "$script_dir/component_parts/manifest.sh" -source "$script_dir/component_parts/language.sh" -source "$script_dir/component_parts/provider.sh" -source "$script_dir/component_parts/displaycontroller.sh" -source "$script_dir/component_parts/view.sh" -source "$script_dir/component_parts/defaultview.sh" - -echo "Component framework generated successfully!" -echo "You should manually edit the manifest file before checkin" diff --git a/bin/component_zip.sh b/bin/component_zip.sh deleted file mode 100644 index 56de801..0000000 --- a/bin/component_zip.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -################################################################################################### -# INSTRUCTIONS -# Move to the directory of the component -# Run this script with component name (com_name) -################################################################################################### - -# Check if the component name is provided as the first parameter -if [ -n "$1" ]; then - componentName="$1" -else - # Prompt for the name of the component - read -p "Enter the name of the component (including com_): " componentName -fi - -# Check if the component name starts with 'com_' -if [[ $componentName != com_* ]]; then - echo "Invalid component name. The name should start with 'com_'" - exit 1 -fi - -# Check if the component folder exists -if [ ! -d "$componentName" ]; then - echo "Component folder '$componentName' does not exist." - exit 1 -fi - -# Extract the name by removing the first four characters -name="${componentName:4}" - -# Read the contents of $name/$name.xml file -xml_file="$componentName/$name.xml" -if [ -f "$xml_file" ]; then - xml_contents=$(cat "$xml_file") -else - echo "XML file '$xml_file' not found." - exit 1 -fi - -# Extract the version from the XML contents -regex="(.*?)<\/version>" -if [[ $xml_contents =~ $regex ]]; then - version="${BASH_REMATCH[1]}" -else - echo "Version not found in the XML file." - exit 1 -fi - -zip_filename="$name-$version.zip" -cd "$componentName" && 7z a "../$zip_filename" *