moved component maker into it's own repo:
This commit is contained in:
parent
9add26b186
commit
f1e74c60fb
@ -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 <<EOM > admin/tmpl/${name}/default.php
|
||||
<?php defined('_JEXEC') or die('Restricted Access'); ?>
|
||||
|
||||
<h2>Hello ${name}!</h2>
|
||||
|
||||
EOM
|
@ -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 <<EOM > admin/src/Controller/DisplayController.php
|
||||
<?php
|
||||
namespace Harvst\\Component\\${name^}\\Administrator\\Controller;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
|
||||
class DisplayController extends BaseController {
|
||||
|
||||
protected \$default_view = '${name}';
|
||||
|
||||
public function display(\$cachable = false, \$urlparams = array()) {
|
||||
return parent::display(\$cachable, \$urlparams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EOM
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat <<EOM > admin/language/en-GB/en-GB.com_${name}.ini
|
||||
; com_${name}
|
||||
COM_${name^^}_DESCRIPTION="Placeholder description, edit in language file"
|
||||
EOM
|
||||
|
||||
|
@ -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 <<EOM > ${name}.xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="component" method="upgrade">
|
||||
<name>${name}</name>
|
||||
<creationDate>${current_date}</creationDate>
|
||||
<author>${JOOMLA_USER}</author>
|
||||
<authorEmail>${EMAIL}</authorEmail>
|
||||
<authorUrl>https://www.example.com/</authorUrl>
|
||||
<copyright>Copyright (C) ${current_year} ${JOOMLA_USER}, All rights reserved.</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
|
||||
<version>0.0.1</version>
|
||||
|
||||
<!-- The description is optional and defaults to the name -->
|
||||
<description>COM_${name^^}_DESCRIPTION</description>
|
||||
|
||||
<namespace path="src/">Harvst\Component\\${name^}</namespace>
|
||||
|
||||
<administration>
|
||||
<!-- The link that will appear in the Admin panel's "Components" menu -->
|
||||
<menu link="index.php?option=com_${name}">${name^}</menu>
|
||||
<files folder="admin">
|
||||
<folder>language</folder>
|
||||
<folder>services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages folder="admin">
|
||||
<!-- TODO: It's there but not working -->
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_${name}.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
</extension>
|
||||
EOM
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat <<EOM > admin/services/provider.php
|
||||
|
||||
<?php defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
|
||||
use Joomla\CMS\Extension\ComponentInterface;
|
||||
use Joomla\CMS\Extension\MVCComponent;
|
||||
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
|
||||
return new class implements ServiceProviderInterface {
|
||||
|
||||
public function register(Container \$container): void {
|
||||
\$container->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
|
@ -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 <<EOM > admin/src/View/${name^}/HtmlView.php
|
||||
<?php
|
||||
|
||||
namespace Harvst\\Component\\${name^}\\Administrator\\View\\${name^};
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
|
||||
class HtmlView extends BaseHtmlView {
|
||||
|
||||
function display(\$tpl = null) {
|
||||
parent::display(\$tpl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EOM
|
@ -1,81 +0,0 @@
|
||||
#!/bin/bash
|
||||
# create_component.sh componentName
|
||||
|
||||
# Determine the directory where the script is located
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/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"
|
@ -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>(.*?)<\/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" *
|
Reference in New Issue
Block a user