ochotags / ochot-scripts
Scripts to boost development tasks
README
Este repositorio es una ayuda al desarrollador de una serie de abreviaturas de comandos para poder trabajar más rápido.
Estos comandos engloban a GIT, Shopify CLI, PHP, Composer y Laravel (dentro de Laravel, tenemos Artisan, Laravel Pint y otros).
Installation via Composer Locally
You must add the package in the "Require" section or "Require-dev":
"require": {
...
"ochotags/ochot-scripts": "^1.0.0",
...
},
Finally, you must execute the composer update command:
$ composer update
Or, you can use composer to add it:
$ composer require --dev ochotags/ochot-scripts
Installation via Composer Globally
If you are going to use this package on more projects, maybe you could install it globally on your computer:
$ composer global require ochotags/ochot-scripts
This command works from the version package 1.1.2.0 and above.
Short commands
You can use the next tip to create a linux variable in the terminal. Then you can short the commands.
You need to create a file named .bashrc in the home directory of the project. For example:
SCRIPTFOLDER="./vendor/ochotags/ochot-scripts/"
echo "\$SCRIPTFOLDER"
echo $SCRIPTFOLDER
Remember to add this file to the .gitignore file of your project.
When the file is created, you can use the following command to execute it and set the variable:
$ source .bashrc
And then, in the terminal, you can use the variable:
$ echo $SCRIPTFOLDER
If you prefer you can create a command file to all the projects in the user home directory.
https://superuser.com/a/405373
When you have the variable, you can use the following command to execute the commands, for example:
$ $SCRIPTFOLDER/git/pull.sh
Or you can type $SCR
and press tab key to get the complete variable name in the console.
I hope this helps you.
You can find a .bashrc.example in this project at:
./vendor/ochotags/ochot-scripts/.bashrc.example
Alias y comandos cortos
Gracias a la inclusión del fichero .bashrc
podemos crear alias y comandos cortos para que en pocas teclas tengamos los comandos. Por ejemplo, en .bashrc
tenemos:
alias gitps='$SCRIPTFOLDER/git/push.sh'
alias gitpl='$SCRIPTFOLDER/git/pull.sh'
En este caso, podemos usar el comando gitps
para hacer un commit y push.
Variables
Por comodidad para la compilación de aplicaciones de Shopify hemos creado unas variables globales:
SHOPIFY_API_KEY=123456789
SHOPIFY_API_SECRET=123456789
SHOPIFY_API_VERSION=2023-10
SHOPIFY_SCOPES=write_products,write_orders
export SHOPIFY_API_KEY
export SHOPIFY_API_SECRET
export SHOPIFY_API_VERSION
export SHOPIFY_SCOPES
Es una interesante ayuda porque luego podemos hacer comandos comunes para todos los proyectos:
npm run build -- --client-id=$SHOPIFY_API_KEY
En el comando de arriba compilamos el frontend con la ayuda de la variable $SHOPIFY_API_KEY
.
Extra Tip
Si quieres puedes hacer que se ejecute el comando source
de forma automática cuando se inicia el terminal Git Bash.
Podemos hacerlo creando un fichero llamado .profile
en tu carpeta de usuario de Windows. Por ejemplo, mi usuario de Windows es macorredor
. Por tanto, en la carpeta:
C:\Users\macorredor
Creamos el fichero .profile
con el siguiente contenido:
source ./.bashrc
Con este comando cada vez que abrimos Git Bash en un directorio en concreto, el bash intentará ejecutar el comando, por tanto, si tenemos un fichero llamado .bashrc
intentará ejecutarlo:
Si no existiera el fichero en cuestión, no pasará nada, salvo que saldrá un mensaje de error:
Command List
Common Commands
// Mostrar la ayuda con todos los comandos del proyecto
$ vendor/ochotags/ochot-scripts/common/help.sh
GIT Commands
// Commit and push changes
$ vendor/ochotags/ochot-scripts/git/push.sh [--master] "Commit message"
// Pull changes
$ vendor/ochotags/ochot-scripts/git/pull.sh [--master]
// New tag
$ vendor/ochotags/ochot-scripts/git/new_tag.sh "v1.0.0"
// Force LF in your project
$ vendor/ochotags/ochot-scripts/git/use_lf.sh
// Force CRLF in your project
$ vendor/ochotags/ochot-scripts/git/use_crlf.sh
// Get the status
$ vendor/ochotags/ochot-scripts/git/status.sh
// We need to pull from remote before push changes
$ vendor/ochotags/ochot-scripts/git/conflict.sh [--undo-commit]
// Stash local changes
$ vendor/ochotags/ochot-scripts/git/stash.sh
// Stash pop
$ vendor/ochotags/ochot-scripts/git/stashpop.sh
// Go to other branch
$ vendor/ochotags/ochot-scripts/git/checkout.sh <branch-name>
// Create a new branch and push origin contents
$ vendor/ochotags/ochot-scripts/git/newcheckout.sh <branch-name>
// Remove a file from repository
$ vendor/ochotags/ochot-scripts/git/remove.sh [--remote] <file-name>
// Rename a branch name
$ vendor/ochotags/ochot-scripts/git/rename.sh <old-name> <new-name>
Shopify Commands
// Get Shopify Themes
// You must update the config.yml with the information of the private app or you can
// send this information through script params
$ vendor/ochotags/ochot-scripts/shopify/getlist.sh [-p password] [-s store-domain]
// Download first time Shopify Theme
// You must update the config.yml with the information of the private app or you can
// send this information through script params.
// This script generates the config.yml with our template.
$ vendor/ochotags/ochot-scripts/shopify/gettheme.sh [-p password] [-s store-domain] [-t theme-id] [-o]
[-o] Skips the creation of config.yml with our template and leaves the created file
by the Shopify Theme application.
// Dowloand all files of the Shopify Theme
$ vendor/ochotags/ochot-scripts/shopify/download.sh
// Init the synchronization process
$ vendor/ochotags/ochot-scripts/shopify/sync.sh
Shopify CLI Commands
// Compile Project
$ vendor/ochotags/ochot-scripts/shopifycli/compile.sh [--master]
// Run webhooks
$ vendor/ochotags/ochot-scripts/shopifycli/webhooks.sh [--webhook=<name>] [--url=<url>] [--client-secret=<token>]
// Serve development project
$ vendor/ochotags/ochot-scripts/shopifycli/serve.sh
PHP Commands
Change the file incl.sh to define the folder with the local PHP folder.
// Run the PHP executable
$ vendor/ochotags/ochot-scripts/php/php.sh <command-parameter>
// Run Composer command
$ vendor/ochotags/ochot-scripts/php/composer.sh <command-parameter>
// Run Artisan command
$ vendor/ochotags/ochot-scripts/php/php_artisan_run.sh <command-parameter>
// Run Artisan migrate command
$ vendor/ochotags/ochot-scripts/php/php_artisan_migration.sh [--refresh] [--seed]
// Create a Laravel Model
$ vendor/ochotags/ochot-scripts/php/php_artisan_add_model.sh ModelName [Options]
// Run Artisan serve command. Default port: 9090
$ vendor/ochotags/ochot-scripts/php/php_artisan_serve.sh [port-number]
// Run Laravel Pint. It should be installed first with Composer.
$ vendor/ochotags/ochot-scripts/php/php_artisan_pint.sh
// Run Pest Tests. Pest should be installed first with Composer.
$ vendor/ochotags/ochot-scripts/php/php_artisan_pest.sh
// Run Clear Caches Commands
$ vendor/ochotags/ochot-scripts/php/php_artisan_clear_caches.sh
// Run IDE Helper command. https://github.com/barryvdh/laravel-ide-helper
$ vendor/ochotags/ochot-scripts/php/php_artisan_ide_helper.sh
Other Commands
Here we have added other commands:
// Start Database Windows Service. Requires de Service Name in Environment Variables ($LOCAL_DATABASE_SERVICENAME).
$ vendor/ochotags/ochot-scripts/other/run_database.sh
// Or you should run this command in PowerShell ($LOCAL_DATABASE_SERVICENAME).
> vendor/ochotags/ochot-scripts/other/run_database.ps1
// Start Ngrok Tunnel
$ vendor/ochotags/ochot-scripts/other/tunnel_ngrok.sh
// Start Clousflared Tunnel
$ vendor/ochotags/ochot-scripts/other/tunnel_cloudfared.sh