Giter Club home page Giter Club logo

jext-cli's Introduction

JEXT-CLI

wideGif

JEXT-CLI is a command-line application for creating Joomla! 4 components using just a simple command. This tool will help you to reduce your job for creating a component. It will provide you a boilerplate for Joomla! 4 component.

Installation

The installation process is too easy. You can install it from the source code.

Prerequisites

You need PHP CLI, and composer are installed in your machine before proceeding next steps.

Note: These processes are only for Linux and macOS. For Windows, these may not work. If you can implement the installation in a Windows machine, please share the idea.

Steps:

  1. Clone the repository using git git clone https://github.com/ahamed/jext-cli.git or Download Zip from github.
  2. Extract the zip file.
  3. Go to the directory, run cd jext-cli
  4. Install project dependencies, run composer install
  5. Regenerate the class lists for auto-loading, run composer dump-autoload -o
  6. Run chmod +x install.sh for making the install.sh file executable.
  7. Run ./install.sh, it will ask for the password, just type your password and hit enter.

If no error happens, then you are done installing the jext-cli tool. Now you can use it globally by using a terminal.

Usage

This tool is only for Joomla! 4. So you need to-

  1. Download and Install Joomla 4.
  2. Go to the Joomla! project's root directory, run cd path/to/the/project/root
  3. Run jext-cli --version, if it shows you the version message, then the jext-cli is installed correctly in your machine.

Creating a new Joomla! component:

Syntax

jext-cli --component|-c <name>
  • For creating a new Joomla! 4 component just run jext-cli --component <name>. Here the <name> would be replaced by your component name, and the name should be without com_ prefix. If you add the com_ prefix, then don't worry, this will be sanitized.

  • After that you will be asking for-

    • Author name (What is the name of the component author. If skip jext-cli will take the current username as the author name.)
    • Author Email (The email address of the component author. If skip then it will be empty.)
    • Author Url (The author website url, If skip then it will be empty.)
    • Description (The component description. If skip then it will be empty.)
    • Copyright (Copyright information, default (C) {year}, {Author name}.)
    • License (Component license information, default MIT)
    • Version (Component initial version number, default 1.0.0)
    • Namespace (The component's namespace, default Joomla\Component\<ComponentName>. Using the default is recommended.)
    • Do you confirm component creation? (Hit enter if everything is okay. If not then type no and hit enter.)

Congratulation! You have successfully created your first Joomla! 4 component using jext-cli tool. By default jext-cli --component <name> command creates a component with two default views. One for creating Notes and another for showing the list of Icomoon icons with live search facilities. If you don't want these views then add a flag --no-sample-view with the create command. So the command would be jext-cli --component <name> --no-sample-view

Creating a view to the component:

You can also add a view to the component. A view comes with all the required Model, Controller and View files.

Syntax:

jext-cli --view [-f|--front [-b|--back [-bt|--both]]]

The third argument is optional. If you skip it, then the view is generated for the backend/administrator. If you want the view for the frontend then the third argument would be -f or --front. You can also create a view for both frontend and backend. For that use the third argument as -bt or --both.

Available commands

  1. jext-cli --view - for creating a view for the administrator part.
  2. jext-cli --view -b|--back - same as command 1.
  3. jext-cli --view -f|--front - for creating a view for the frontend.
  4. jext-cli --view -bt|--both - for creating a view for both of the administrator or frontend.

This command will ask you for some information.

  • [required] Component Name (The component name where to put the view)
  • [required] View name (Singular) (The singular name of the view)
  • [optional] View name (Plural) (The plural name of the view. The jext-cli will predict the plural name from the singular name. If you think the prediction is correct then hit enter, otherwise enter the plural name and hit enter.)

Congratulations! You have successfully generated a view. Using these commands create all the views you've required.

Now it's time to check our component. We have to install the component first. For installing the component-

  1. Login as a super user to the administrator panel.
  2. Go to Settings > Discover
  3. Select the component to install and click the Install button from the toolbar.
  4. The component is installed. For checking this go to the Component menu from the left sidebar.

Note: If you install the component after adding all the views, then all the database tables related with the views will be installed along with the component. Also you can find the views as the submenu of the component. But if you add any view after installing the component, then you have to create a database table associate with the view. The jext-cli tool assumes that every view has a database table. For getting the table definition check the install.sql file inside the administrator component folder of the component.

For more information run jext-cli --help or jext-cli -h or just jext-cli and hit enter.

Contribution

For contribution-

  1. Fork the repository.
  2. Clone the forked repository to your local machine.
  3. Create a new branch from the main branch, e.g. git checkout -b new_branch. [Note never work at main if you plan to contribute. Never means never.]
  4. Commit your changes and push to your remote.
  5. Make a pull request (PR) to this repository.

Test

Currently phpcs testing is integrated. If you interested and make a PR then first make sure that you pass the test of phpcs. Testing this is simple, just run-

composer run-script phpcs

Support

If you get any problems then raise an issue here or send me at [email protected] but first option is preferable.

jext-cli's People

Contributors

ahamed avatar siddik-web avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jext-cli's Issues

Fail on windows

Describe the bug
Everithing worked correctly until "Generating the component metadata..."

Then an error happened

Do you confirm component creation [yes]?
Generating the component metadata...
PHP Warning:  file_put_contents(/jext.json): Failed to open stream: Permission denied in C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\BaseController.php on line 141

Warning: file_put_contents(/jext.json): Failed to open stream: Permission denied in C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\BaseController.php on line 141
Metadata generation completed.

Creating component core files...
PHP Fatal error:  Uncaught Exception: You are too early to get the meta data or the `jext.json` file has been deleted! in C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\BaseController.php:108
Stack trace:
#0 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\ComponentController.php(184): Ahamed\Jext\Controllers\BaseController->getMeta('restaurant-mana...')
#1 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\ComponentController.php(328): Ahamed\Jext\Controllers\ComponentController->createComponentFiles()
#2 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Application.php(70): Ahamed\Jext\Controllers\ComponentController->run(Array)
#3 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\bin\jext-cli(11): Ahamed\Jext\Application->run(Array)
#4 {main}
  thrown in C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\BaseController.php on line 108

Fatal error: Uncaught Exception: You are too early to get the meta data or the `jext.json` file has been deleted! in C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\BaseController.php:108
Stack trace:
#0 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\ComponentController.php(184): Ahamed\Jext\Controllers\BaseController->getMeta('restaurant-mana...')
#1 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\ComponentController.php(328): Ahamed\Jext\Controllers\ComponentController->createComponentFiles()
#2 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Application.php(70): Ahamed\Jext\Controllers\ComponentController->run(Array)
#3 C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\bin\jext-cli(11): Ahamed\Jext\Application->run(Array)
#4 {main}
  thrown in C:\Users\User\Downloads\Browser\jext-cli-1.0.0-beta.1\src\Controllers\BaseController.php on line 108

I'm on windows using xampp

PHP 8.0.2 (cli) (built: Feb 3 2021 18:36:40) ( ZTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies

Composer version 2.0.11 2021-02-24 14:57:23

Saving an existing note not possible: error alias already exists

I have installed the default generated component and added two notes. Both notes have a unique alias.

When editing an existing note and then save it, an error occurs: "Another item has the same alias (remember it may be a trashed item)".

I think this is a bug in the store method in /administrator/components/<component_name>/src/Table/NoteTable.php

When creating a view, create a basic default.xml file

Is your feature request related to a problem? Please describe.
It is always easier to start with a framework than with nothing

Describe the solution you'd like
Create default.xml in the new folder directory alongside default.php

Describe alternatives you've considered
Start from scratch

Component SQL creates "notes" table even if --no-sample-view specified

Describe the bug
SQL created in /administrator/components/com_example/sql/install.mysql.utf8.sql for notes table even if --no-sample-view specified

To Reproduce
Steps to reproduce the behavior:

  1. Create a component with jext-cli -c example --no-sample-view
  2. Look at /administrator/components/com_example/sql/install.mysql.utf8.sql

Expected behavior
No table creation

Actual behavior
File contains CREATE TABLE IF NOT EXISTS #__remository_notes etc.

Option to create view with no plural version

Is your feature request related to a problem? Please describe.
Actual applications do not all follow the pattern of list and edit (or similar)

Describe the solution you'd like
An option to not have a plural version of the view in jext-cli --view

Describe alternatives you've considered
Deleting out unwanted views - but this is laborious and unreliable

An option to create a package from a component created using jext-cli

Is your feature request related to a problem? Please describe.
The newly created component needs to be converted into an installable package, a non trivial task

Describe the solution you'd like
A jext-cli command to export a component. Or a script - see possible example below

Describe alternatives you've considered
I wrote a script, see below.

Additional context
Possible bash script for the purpose attached.

jext-pack.txt

Another item has the same alias (remember it may be a trashed item).

I get an error when I try to modify, Save failed with the following error: Another item has the same alias (remember it may be a trashed item).
could it be my mistake?


Resolved

one possible solution is to change src/Table/Table.php row 106 (id!==) to (id!=):

if ($ table-> load (array ('alias' => $ this-> alias)) && ($ table-> id! == $ this-> id || $ this-> id === 0))
{
$ this-> setError (Text :: _ ('COM_NOTES_ERROR_UNIQUE_ALIAS'));

return false;
}

To:

if ($ table-> load (array ('alias' => $ this-> alias)) && ($ table-> id! = $ this-> id || $ this-> id === 0))
{
$ this-> setError (Text :: _ ('COM_NOTES_ERROR_UNIQUE_ALIAS'));

return false;
}

Find a column name issue.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Actual behavior
What did you get except the expected behavior?

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.