From 029066488bbe122058c094f27ce4a854f598a31d Mon Sep 17 00:00:00 2001
From: Apolo Pena <3060702+apolopena@users.noreply.github.com>
Date: Wed, 24 Mar 2021 15:21:40 -0700
Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20MERGE:=20Features=20and=20Fixes?=
=?UTF-8?q?=20for=20version=200.0.4=20(#70)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 📖 DOC: https://github.com/apolopena/gitpod-laravel8-starter/issues/58 Readme: Revamp and add TOC
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/45
* 🤖 TEST: phpmyadmin
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/45
* 🐛 FIX: path
* 🐛 FIX: typo in path
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/45
* 🐛 FIX: remove quotes in sed for phpmyadmin
* 🤖 TEST: special chars
* 🤖 TEST: restore test back to dynamic state
* 🐛 FIX: phpmyadmin config
* 🐛 FIX: @ breaks things when generated string starts with one
* 🐛 FIX: create phpmyadmin db
* 🐛 FIX: spinner
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/45
* 🐛 FIX: credentials
* 🐛 FIX: go back to cp of config.sample.inc.php
* 🤖 TEST: rsync progress
* 👌 IMPROVE: https://github.com/apolopena/gitpod-laravel8-starter/issues/62
* 🐛 FIX: tweak rsync progress
* 🐛 FIX: tweak rsync progress
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: rsync stats, restored spinner for speed
* 🐛 FIX: use native rsync progress option
* 🐛 FIX: colorized rsync stats
* 🐛 FIX: log messages
* 👌 IMPROVE: remove auth, edit comments
* 👌 IMPROVE: Installtion information API for https://github.com/apolopena/gitpod-laravel8-starter/issues/61
* 📖 DOC: comments
* 🤖 TEST: call yarn installs less
* 🤖 TEST: call yarn installs less
* 🐛 FIX: refactor to save calls to yarn install
* 🐛 FIX: refactor to save calls to yarn install
* 🤖 TEST: refactor to save calls to yarn install
* 🐛 FIX: load spinner
* 🐛 FIX: error mix not found
* 🐛 FIX: tweak order
* 🐛 FIX: line 130: printf: --: invalid option
* 🐛 FIX: line 130: printf: --: invalid option
* 🐛 FIX: tweaks
* 🤖 TEST: fix npm error
* 🤖 TEST: error in npm when install react scaffolding
* 🤖 TEST: with no yarn run dev after node modules are installed
* 🤖 TEST: installs
* 🐛 FIX: tweaks for less npm installs can rless running of laravel mix
* 🤖 TEST: tweaks for installs
* 🐛 FIX: install info API, bad regexp
* 🐛 FIX: new logic for installs
* 🐛 FIX: run_laraval_mix_twice
* 🐛 FIX: run_laravel_mix twice in the wrong spot
* 🤖 TEST: run larvel mix twice
* 🤖 TEST: run larvel mix twice
* 🐛 FIX: fresh start on getting out of this hole
* 🤖 TEST: vue install
* 🤖 TEST: adding in laravel mix run when installing laravel/ui
* 🤖 TEST: adding in laravel mix run when installing laravel/ui, remove extraneous condition
* 🤖 TEST: no npm install after install of larvel/ui
* 🤖 TEST: remove inistal npm install
* 🤖 TEST: remove inistal npm install
* 🤖 TEST: remove inistal npm install
* 🤖 TEST: react install
* 🤖 TEST: no front end scaffolding installs, still install node modules
* 🐛 FIX: typo
* 🤖 TEST: no front end scaffolding installs
* 🐛 FIX: conditional
* 📖 DOC: comments
* 🐛 FIX: make successes a silent log
* 🐛 FIX: install conditions, ready to test
* 📖 DOC: fixed and tested one-liners for project creation
* 🐛 FIX: typo in condition
* 🐛 FIX: install node modules blindly to avoid frontend scaffolding overwrite
* 🐛 FIX: remove uneccessary function
* 🐛 FIX: phpmyadmin install
* 🐛 FIX: path to public/phpmyadmin/config.inc.php
* 👌 IMPROVE: enhanced phpmyadmin setup logic
* 👌 IMPROVE: https://github.com/apolopena/gitpod-laravel8-starter/issues/64 Support .starter.env for sensitive data like phpmyadmin credentials
* 🐛 FIX: refactor https://github.com/apolopena/gitpod-laravel8-starter/issues/64, works good
* 🐛 FIX: rename and fix
* 🐛 FIX: path
* 🐛 FIX: file name
* 📖 DOC: https://github.com/apolopena/gitpod-laravel8-starter/issues/66 Add phpMyAdmin section to README.md
* 👌 IMPROVE: no trailing newline for .txt files
* 👌 IMPROVE: https://github.com/apolopena/gitpod-laravel8-starter/issues/65 Add log message to summary
* 📖 DOC: improve message
* 📖 DOC: improve message
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/67 'before' tasks should be logged to file but not to the console
* 👌 IMPROVE: log messages
* 👌 IMPROVE: https://github.com/apolopena/gitpod-laravel8-starter/issues/68 Add help alias
* 👌 IMPROVE: success messages are logged silently
* 👌 IMPROVE: add silent log
* 🐛 FIX: log messages
* 🐛 FIX: logs and comments
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/63
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/41 Rename test-app to laravel8-starter
* 🤖 TEST: force workspace image build
* 🐛 FIX: rsync path
* 🐛 FIX: log message
* 🐛 FIX: message
* 🐛 FIX: message
* 🐛 FIX: message
* 👌 IMPROVE: https://github.com/apolopena/gitpod-laravel8-starter/issues/39 Expand Gitlog with additional emoji and git aliases
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/39 change add to ad, add noadd aliases
* 📖 DOC: update as per https://github.com/apolopena/gitpod-laravel8-starter/issues/39
* 🐛 FIX: summary message
* 🐛 FIX: messaging
* 🐛 FIX: https://github.com/apolopena/gitpod-laravel8-starter/issues/69
* 🐛 FIX: fine tune, logic and logs
* 🐛 FIX: wording
* 🐛 FIX: edit log message
* 🐛 FIX: alias: add changed to ad
* 🐛 FIX: log silent on env injection success
* 🐛 FIX: log msg
* 🤖 TEST: fix broken web preview spinner
* 🤖 TEST: fix for hung preview
* 👌 IMPROVE: hung preview fix
* 🤖 TEST: preview browser fix
* 🤖 TEST: phpmyadmin install=0
* ♻️ REFACTOR: preview browser
* 👌 IMPROVE: preview browser message
* 🐛 FIX: removed preview browser open msg since https://github.com/apolopena/gitpod-laravel8-starter/issues/19 is a gitpod internal bug
* 🤖 TEST: barebones install
* 🤖 TEST: changelog generator
* 🤖 TEST: force workspace image build
* 🤖 TEST: changelog generator
* ⚰️ REMOVE: workaround code for https://github.com/apolopena/gitpod-laravel8-starter/issues/46
* 🤖 TEST: force workspace image build
* 🐛 FIX: init scripts should not depend on eachothers success
* 🤖 TEST: force workspace image build
* 📖 DOC: edit and enhance README
* 🐛 FIX: removed ... from log messages
---
.example.starter.env | 3 -
.gitpod.Dockerfile | 18 +-
.gitpod.yml | 14 +-
.starter.env.example | 5 +
README.md | 353 ++++++++++++------
bash/.bash_aliases | 9 +
bash/before-tasks.sh | 25 +-
bash/change-passwords.sh | 105 ++++++
bash/helpers.sh | 170 ++++++++-
bash/init-complete.sh | 2 +-
bash/init-gitpod.sh | 115 +++---
bash/init-optional-scaffolding.sh | 62 +--
bash/init-phpmyadmin.sh | 135 +++++++
bash/scaffold-project.sh | 20 +-
bash/snippets/editorconfig/laravel-js-2space | 5 +-
bash/snippets/emoji-log | 48 ++-
bash/snippets/grc/rsync-stats | 15 +
.../snippets/messages/help-update-pma-pws.txt | 6 +
.../snippets/messages/phpmyadmin-security.txt | 3 +
bash/utils.sh | 77 +++-
starter.ini | 8 +-
21 files changed, 936 insertions(+), 262 deletions(-)
delete mode 100644 .example.starter.env
create mode 100644 .starter.env.example
create mode 100644 bash/.bash_aliases
create mode 100644 bash/change-passwords.sh
create mode 100644 bash/init-phpmyadmin.sh
create mode 100644 bash/snippets/grc/rsync-stats
create mode 100644 bash/snippets/messages/help-update-pma-pws.txt
create mode 100644 bash/snippets/messages/phpmyadmin-security.txt
diff --git a/.example.starter.env b/.example.starter.env
deleted file mode 100644
index 884f2dd6..00000000
--- a/.example.starter.env
+++ /dev/null
@@ -1,3 +0,0 @@
-# These are used on the first run of the Gitpod workspace
-PHPMYADMIN_USER=
-PHPMYADMIN_PW=
\ No newline at end of file
diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile
index ffb149a8..f275b082 100644
--- a/.gitpod.Dockerfile
+++ b/.gitpod.Dockerfile
@@ -10,22 +10,11 @@ RUN sudo touch /var/log/workspace-init.log \
RUN sudo touch /var/log/xdebug.log \
&& sudo chmod 666 /var/log/xdebug.log
-
-RUN sudo mkdir /var/log/apache2 \
- && sudo chmod 755 /var/log/apache2
-
-RUN sudo touch /var/log/apache2/access.log \
- && sudo chmod 666 /var/log/apache2/access.log
-
-RUN sudo touch /var/log/apache2/error.log \
- && sudo chmod 666 /var/log/apache2/error.log
-
-RUN sudo touch /var/log/apache2/other_vhosts_access.log \
- && sudo chmod 666 /var/log/apache2/other_vhosts_access.log
RUN sudo apt-get update -q \
&& sudo apt-get install -y rsync \
- && sudo apt-get install -y grc
+ && sudo apt-get install -y grc \
+ && sudo apt-get install -y progress
RUN wget http://xdebug.org/files/xdebug-3.0.2.tgz \
&& tar -xvzf xdebug-3.0.2.tgz \
@@ -42,8 +31,9 @@ RUN sudo bash -c ". /tmp/update-composer.sh" && rm /tmp/update-composer.sh
# gitpod trick to bypass the docker caching mechanism for all lines below this one
# just increment the value each time you want to bypass the cache system
-ENV INVALIDATE_CACHE=125
+ENV INVALIDATE_CACHE=130
+COPY --chown=gitpod:gitpod bash/.bash_aliases /home/gitpod
COPY --chown=gitpod:gitpod bash/utils.sh /tmp
COPY --chown=gitpod:gitpod starter.ini /tmp
COPY --chown=gitpod:gitpod bash/scaffold-project.sh /tmp
diff --git a/.gitpod.yml b/.gitpod.yml
index 8a533214..4cb94735 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -14,9 +14,10 @@ ports:
tasks:
- before: bash bash/before-tasks.sh
init: |
- bash bash/init-gitpod.sh &&
- bash bash/init-optional-scaffolding.sh &&
- bash bash/init-project.sh &&
+ bash bash/init-gitpod.sh
+ bash bash/init-optional-scaffolding.sh
+ bash bash/init-phpmyadmin.sh
+ bash bash/init-project.sh
bash bash/init-complete.sh
name: Startup
- openMode: split-left
@@ -43,9 +44,10 @@ tasks:
. bash/third-party/spinner.sh &&
start_spinner "Opening preview when system is ready..."
gp sync-await gitpod-inited &&
- default_server=$(bash bash/utils.sh parse_ini_value starter.ini development default_server); \
- open_preview $default_server &&
- stop_spinner $?
+ stop_spinner 0 &&
+ __port=$(bash bash/helpers.sh get_default_server_port); \
+ gp await-port $__port &&
+ gp preview $(gp url $__port)
name: Main Terminal
vscode:
diff --git a/.starter.env.example b/.starter.env.example
new file mode 100644
index 00000000..c8624f6e
--- /dev/null
+++ b/.starter.env.example
@@ -0,0 +1,5 @@
+# These values will be used by the script bash/change-passwords.sh
+# All varaiable mus be present in .starter.env
+# All varaibles must have a value set
+PHPMYADMIN_SUPERUSER_PW=
+PHPMYADMIN_CONTROLUSER_PW=
\ No newline at end of file
diff --git a/README.md b/README.md
index ff7f73f0..0a2a5621 100644
--- a/README.md
+++ b/README.md
@@ -1,129 +1,168 @@
-# Laravel 8 Gitpod Starter
+## Introduction: Laravel 8 Gitpod Starter
🚀
-This a Laravel 8 starter project designed as a starting point for you. Once you have properly copied this repository you may add and change the codebase to your hearts desire 💞. You may also want to save any of the information you find useful on this README page before you overwrite it with information about your own project.
-
-[![Try it out on on Gitpod.io](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://github.com/apolopena/gitpod-laravel8-starter) with [![emoji-log](https://cdn.rawgit.com/ahmadawais/stuff/ca97874/emoji-log/flat-round.svg)](https://github.com/ahmadawais/Emoji-Log/) built into the Gitpod environment.
-
-This project is designed to run and be developed in a [Gitpod](https://gitpod.io/) environment but can be deployed and developed locally. See the **local development outside of Gitpod** section for more details. Live deployment of this project can of course be done anywhere and that is up to you. The project will be running live on Gitpod, however the project only stays open for a small amount of time (usually 30 minutes) which is counted against your Gitpod account hours. A free Gitpod account gets you 50 hours of workspace time a week.
-
-### Requirements ###
+Laravel 8 Gitpod Starter is a [Laravel 8](https://laravel.com/docs/8.x/) 'starter project' designed to be developed in the cloud on the [Gitpod](https://www.gitpod.io/) platform. The core of this project is a simple configuration file and a series of bash scripts that set up a [LAMP](https://en.wikipedia.org/wiki/LAMP_(software_bundle)) stack in the cloud with options to install and auto-configure various popular libraries, authorization, and front-end project scaffolding such as React, Vue, and Bootstrap.
+Just [copy this repository](#tldr-quick-setup---create-a-new-project-repository-from-this-repository) into a new project repository of your own, edit the `starter.ini` file to your liking and you are ready to develop your project in the cloud.
+
+[![Try it out on on Gitpod.io](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://github.com/apolopena/gitpod-laravel8-starter) with [![emoji-log](https://cdn.rawgit.com/ahmadawais/stuff/ca97874/emoji-log/flat-round.svg)](https://github.com/ahmadawais/Emoji-Log/) built into the environment.
+
+
+
+
+# Table of Contents
+
+1. [Introduction: Laravel 8 Gitpod Starter](#introduction-laravel-8-gitpod-starter)
+2. [Requirements](#Requirements)
+3. [Setting Up](#Setting-Up)
+ - 3.1 [Tl;dr Quick Setup](#tldr-quick-setup---create-a-new-project-repository-from-this-repository)
+ - 3.2 [Breakdown of the Steps to Create a new Project Repository](#breakdown-of-the-steps-for-creating-a-new-project-from-this-repository)
+ - 3.4 [Creating a new workspace in Gitpod from your new GitHub project repository](#creating-a-new-workspace-in-gitpod-from-your-new-github-project-repository)
+4. [Running the Client](#running-the-client)
+5. [Pushing the Scaffolding Files to Your Remote Repository](#pushing-the-scaffolding-files-to-your-remote-repository)
+ - 5.1 [Gitpod account permissions](#gitpod-account-permissions)
+ - 5.2 [GitHub email protection](#GitHub-email-protection)
+6. [Starter Project Configuration](#Starter-Project-Configuration)
+ - 6.1 [Development Servers](#development-servers)
+ - 6.2 [Changing the default server](#changing-the-default-server)
+ - 6.3 [Running more than one server at a time](#running-more-than-one-server-at-a-time)
+7. [Debugging](#debugging)
+ - 7.1 [The default development server](#the-default-development-server)
+ - 7.2 [Specific development servers](#specific-development-servers)
+ - 7.3 [Setting breakpoints](#setting-breakpoints)
+ - 7.4 [Debugging Blade templates](#debugging-blade-templates)
+ - 7.5 [Tailing the Xdebug Log](#tailing-the-xdebug-log)
+8. [phpMyAdmin](#phpmyadmin)
+ - 8.1 [Installing phpMyAdmin](#installing-phpmyadmin)
+ - 8.2 [Security Concerns](#security-concerns)
+ - 8.3 [Securing phpMyAdmin](#securing-phpmyadmin)
+9. [Generating a CHANGELOG.md Using github-changelog-generator](#generating-a-changelogmd-using-github-changelog-generator)
+ - 9.1 [Setting up an Access Token for github-changelog-generator](#setting-up-an-access-token-for-github-changelog-generator)
+10. [Project Specific Bash Code for Gitpod](#project-specific-bash-code-for-gitpod)
+11. [Ruby Gems](#ruby-gems)
+12. [Emoji-log and Gitmoji](#emoji-log-and-gitmoji)
+13. [Local Development Outside of Gitpod](#local-development-outside-of-gitpod)
+14. [Deployment Outside of Gitpod](#deployment-outside-of-gitpod)
+15. [Thanks](#thanks)
+
+
+
+## Requirements
- A [GitHub](https://github.com/) account (a free account is fine)
- A [GitPod](https://www.gitpod.io/) account (a free account is fine)
-
+
-## Setting Up ##
+## Setting Up
-Gitpod will use the name of GitHub repository you use as the name of the project so make sure you name your new repository accordingly. There are many ways to copy a repository, blast away the history and name it something new and call it your own. Here is a guide you can follow if you like.
+Gitpod will use the name of your GitHub repository as the Laravel project name so make sure you name your project repository accordingly. There are many ways to copy a repository but when using this starter proejct it is advised that you copy it, delete the git history and give it a new name.
+You may also just fork this repository if you simply want to dabble with the starter project but do no intend to make it a standalone project with it's own name.
+### Tl;dr Quick Setup - Create a new project repository from this repository
----
+1. Make a new repository from your GitHub account.
+2. On your local machine copy and paste the below one-liner command into your terminal.
+ - Make sure you replace the `PLACEHOLDER` values with your GitHub user name and new GitHub repository name
-### Tl;dr Quick Setup ###
+```bash
+__new_repo_project_name=PLACEHOLDER; __github_username=PLACEHOLDER; mkdir "$__new_repo_project_name" && cd "$__new_repo_project_name" && git clone https://github.com/apolopena/gitpod-laravel8-starter.git . && rm -rf .git && git init && git add -A && git commit -m "initial commit built from https://github.com/apolopena/gitpod-laravel8-starter" && git remote add origin "https://github.com/$__github_username/$__new_repo_project_name.git" && git branch -m main && git push -u origin main
+```
-1. Make a new repository from your GitHub account.
-2. On your local machine run these commands in your shell. Ensure that the NEW_PROJECT_REPO_NAME matches the name of the repository you created in step 1. You can copy and paste these commands. You run these commands one at a time but make sure to omit the && at the end of each line.
+**Note**: You may also create a new project from a *branch* of this repository by using the below one-liner. Make sure you replace the `PLACEHOLDER` values with your branch name, new GitHub repository name and GitHub user name respectively. The branch name must be a valid remote branch.
```bash
-mkdir NEW_PROJECT_REPO_NAME &&
-cd NEW_PROJECT_REPO_NAME &&
-git clone https://github.com/apolopena/gitpod-laravel8-starter.git . &&
-rm -rf .git &&
-git init &&
-git add -A &&
-git commit -m "initial commit built from https://github.com/apolopena/gitpod-laravel8-starter" &&
-git remote add origin https://github.com/GITHUB_USERNAME/NEW_PROJECT_REPO_NAME.git &&
-git branch -m main &&
-git push -u origin main
+__branch=PLACEHOLDER; __new_repo_project_name=PLACEHOLDER; __github_username=PLACEHOLDER; mkdir "$__new_repo_project_name" && cd "$__new_repo_project_name" && git clone https://github.com/apolopena/gitpod-laravel8-starter.git -b "$__branch" --single-branch . && rm -rf .git && git init && git add -A && git commit -m "initial commit built from the $__branch branch of https://github.com/apolopena/gitpod-laravel8-starter" && git remote add origin "https://github.com/$__github_username/$__new_repo_project_name.git" && git branch -m main && git push -u origin main
```
----
+ You can now skip to the section of how to [initialize your Gitpod workspace](#creating-a-new-workspace-in-gitpod-from-your-new-github-project-repositor) if you like or just read on.
-***Or read on for a more detailed explanation of the recommended steps.***
+### Breakdown of the steps for creating a new project from this repository
-- First copy this GitHub repository into a new GitHub repository of your own and of course be sure to name that repository as the name of your project. These instructions assume you have a bash or bash like shell to work with but if you dont you can figure out on your own.
+*Copy this GitHub repository into a new GitHub repository of your own and of course be sure to name that repository with the name of your project. These instructions assume you have a bash or bash like shell to work with but if you don't you will have to figure out the equivalent commands on your own.*
- 1. In a web browser, [make a new repository in github](https://docs.github.com/en/github/getting-started-with-github/create-a-repo).
- 2. On your local machine create a directory that has the *same name* as your newly created repository in the previous step. For the sake of instruction lets say you named the repo NEW_PROJECT_REPO_NAME.
+ 1. In a web browser, [make a new repository in GitHub](https://docs.github.com/en/github/getting-started-with-github/create-a-repo).
- - `mkdir NEW_PROJECT_REPO_NAME`
+ 2. On your local machine create a directory that has the *same name* as your newly created repository in the previous step. For the sake of instruction lets say you named the repo NEW_PROJECT_REPO_NAME.
- 3. Move into your newly created local folder.
+ - > run `mkdir NEW_PROJECT_REPO_NAME`
- - `cd NEW_PROJECT_REPO_NAME`
+ 3. Move into your newly created local folder.
- 4. Clone this repository into your newly created local folder. Pay close attention to the *.* at the end of this command as you do not want and extra folder named gitpod-laravel8-starter in your project repo. You may use the SSH URL is you like. This example uses the https URL.
+ - > run `cd NEW_PROJECT_REPO_NAME`
- - `git clone https://github.com/apolopena/gitpod-laravel8-starter.git .`
+ 4. Clone this repository into your newly created local folder. Pay close attention to the `.` at the end of this command as you do not want and extra folder named gitpod-laravel8-starter in your project repo. You may use the SSH URL if you like. This example uses the HTTPS URL.
- 5. Delete all the git history (important step).
+ - > run `git clone https://github.com/apolopena/gitpod-laravel8-starter.git .`
- - `rm -rf .git`
+ 5. Delete all the git history (important step).
- 6. Initialize the local git repository.
+ - > run `rm -rf .git`
- - `git init`
+ 6. Initialize the local git repository.
- 7. Add all the files to the local git repository.
+ - > run `git init`
- - `git add -A`
+ 7. Add all the files to the local git repository.
- 8. Commit all the files to the local git repository.
+ - > run `git add -A`
- - `git commit -m "initial commit built from https://github.com/apolopena/gitpod-laravel8-starter"`
+ 8. Commit all the files to the local git repository.
- 9. Add the URL for the remote repository where your local repository will be pushed to. You can use SSH or HTTPS. This example uses https. If you don't know how to find the remote URL for your repository you read [this](https://checkmarx.atlassian.net/wiki/spaces/KC/pages/131432811/GitHub+-+Tips+on+Finding+Git+GitHub+Repository+URLs#:~:text=Tip%20to%20find%20the%20Github,link%20as%20a%20regular%20URL.).
+ - > run `git commit -m "initial commit built from https://github.com/apolopena/gitpod-laravel8-starter"`
+
+ 9. Add the URL for the remote repository where your local repository will be pushed to. You can use SSH or HTTPS as mentioned in step 4. If you don't know how to find the remote URL for your repository you read [this](https://checkmarx.atlassian.net/wiki/spaces/KC/pages/131432811/GitHub+-+Tips+on+Finding+Git+GitHub+Repository+URLs#:~:text=Tip%20to%20find%20the%20Github,link%20as%20a%20regular%20URL.).
- The command will look something like this:
- `git remote add origin https://github.com//NEW_PROJECT_REPO_NAME.git`
+ - Make sure you swap out \ with your GitHub user name.
- 10. Create the local main branch. NOTE: main branches are now called `main` and are no longer called `master`.
-
- - `git branch -m main`
+ 10. Create the local main branch. Note: main branches are now called `main` and are no longer called `master`.
- 11. Finally push your local repository main branch to the remote upstream on the GitHub servers.
+ - > run `git branch -m main`
- - `git push -u origin main`
+ 11. Finally push your local repository main branch to the remote upstream on the GitHub servers.
+ - > run `git push -u origin main`
-- Secondly you need to build out the Gitpod workspace for the first time. Gitpod makes this easy. One simple URL builds out the whole thing. Lets call this URL the Gitpod workspace build URL.
+### Creating a new workspace in Gitpod from your new GitHub project repository
- 1. Paste URL your newly created GitHub repository to the end of the special Gitpod URL, **https://gitpod.io/#/**.
+Create a Gitpod workspace for the first time. Gitpod makes this easy. One simple URL deploys the entire system.
- - For example if your repository URL is **https://github.com/myusername/myprojectname** then the Gitpod workspace build URL needs to look like this:
+ - Paste URL your newly created GitHub repository to the end of the special Gitpod URL, **https://gitpod.io/#/**.
+ - For example if your repository URL is **https://github.com/myusername/myprojectname** then the Gitpod workspace build URL needs to look like this:
- **https://gitpod.io/#/https://github.com/myusername/myprojectname**
+ - Note: Gitpod also supports creating a workspace from a branch by using the branch URL.
-- Finally build out the Gitpod workspace by pasting the Gitpod you obtained in the previous step into your browser and hit enter.
-
- 1. The first time around and entire online development environment complete with and IDE is being built from a custom docker container so this will take some time. Scaffolding for the Laravel 8 project and debugging capabilities are also created the first time you build the workspace so it will be up to you to commit those newly created files to your repository once you see that the build was successful. more on that below
- 2. Gitpod will cache subsequent requests to your workspace and when you restart the workspace it will be much quicker than the initial build.
- 3.
-## Running the client ##
+Initialize the Gitpod workspace by pasting the Gitpod URL you created in the previous step into your browser.
-A preview browser should automatically open and display the Laravel start page. This page is being served by the default web server. The code for this page is in `/resources/views/welcome.blade.php` Please read the [Gitpod documentation](https://www.gitpod.io/docs/) if you want to use this amazing system to its fullest potential. In the IDE there is a UI for hiding the preview browser panel and for launching the preview browser in a separate window. Look on the right side area of the IDE for these controls.
+Initializing the workspace for the first time can take up to 5 or 6 minutes. Subsequent starts of the workspace should be much quicker due to caching mechanisms.
+ - When the workspace is created for the first time an entire online development environment complete with an IDE is deployed along with an addtional installations you have set in `starter.ini`. Scaffolding files for the Laravel 8 project and debugging capabilities are also created the first time you build the workspace so it will be up to you to push those newly created files to your repository before you get started developing your project.
+
-## Pushing files to your remote repository ##
+## Running the Client
-If the results log shows success, you should push the newly created project files to your remote repository.
+A preview browser should automatically open and display the Laravel start page. This page is being served by the default web server which is set in `starter.ini`. The code for this page is in `/resources/views/welcome.blade.php` In the IDE there is a UI for hiding the preview browser panel and for launching the preview browser in a separate window. Look on the right side area of the IDE for these controls.
-*If you do not push the newly created project files to your remote repository they will be recreated every time you create a new Gitpod workspace.*
+Note: Gitpod is constantly being improved such as being able to choose the IDE container you want to use. Because of this instructions may vary from IDE to IDE. Currently the preview browser is not available with the VSCode IDE.
+
+## Pushing the Scaffolding Files to Your Remote Repository
-**Gitpod account permissions**
+If the results log shows success, you should push the newly created project files to your remote repository.
-You may need to allow Gitpod additional permissions to push to your repository so if you come across an issue like [this one](https://community.gitpod.io/t/i-cant-push-my-changes-to-my-github-remote-repository/629), that is what you will need to do.
+*If you do not push the newly created project files to your remote repository they will be recreated every time you create a new Gitpod workspace until you do so.*
+### Gitpod account permissions
+You may need to allow Gitpod additional permissions to push to your repository so if you come across an issue like [this one](https://community.gitpod.io/t/i-cant-push-my-changes-to-my-github-remote-repository/629), that is what you will need to do.
-**GitHub email protection**
+### GitHub email protection
If your GitHub account uses the protected email feature and the email address you are using in your git configuration looks something like this:
@@ -135,97 +174,96 @@ you may encounter an error that looks something like this:
The easiest way to get past this error is to uncheck the box labeled "**Block command line pushes that expose my email**" under Settings-->Emails in your GitHub account.
-If you don't want to do this then you can edit the `~/.gitconfig` file in your Gitpod workspace to use your protected email address as Gitpod defaults to using the unprotected email address for your GitHub account. Please note that if you do this you will have to make this change for __every_ workspace you create and that become cumbersome.
-
+If you don't want to do this then you can edit the `~/.gitconfig` file in your Gitpod workspace to use your protected email address since Gitpod defaults to using the unprotected email address for your GitHub account. Please note that if you do this you will have to make this change for _every_ workspace you create.
+
## Starter Project Configuration
-This starter project is not fully opinionated. You can control many aspects of the development environment and the Laravel project scaffolding.
-
-The file `starter.ini` in the root of the project allow you to configure optional installations and other configurations. See the comments in that file for what you can do. Simply change values in `starter.ini`, push those changes to your repo and create a new Gitpod workspace from that repo and your new configurations will be enabled.
+This starter project tries to be as less opinionated as possible. A configuration file has been provided to allow you to control many aspects of the development environment and the Laravel project scaffolding.
-The exception right now is the optional installation of `phpmyadmin`. This optional installation works however please see this [issue](https://github.com/apolopena/gitpod-laravel8-starter/issues/28) for more details.
+The file `starter.ini` in the root of the project allows you to configure optional installations and other various configurations. See the comments in `starter.ini` for what you can do with it. Simply change values in `starter.ini`, push those changes to your repository, create a new Gitpod workspace from that repo and your new configurations will be enabled.
+There is an exception regarding the installation of `phpmyadmin`. This optional installation works however it is prone to be cached by Docker. Please see this [issue](https://github.com/apolopena/gitpod-laravel8-starter/issues/28) for more details.
+In general it is best to set values in `starter.ini` just once before you create your workspace for the first time.
-### Development Servers
+### Development Servers
This starter project comes pre packaged with two development servers.
- Apache2
- PHP Development Sever
-By default the server listed in `starter.ini` will be the server used. You can however run both servers at the same time or change your default sever.
-You may also run the php development server manually via the command `php artisan serve`.
+By default the server listed in `starter.ini` will be the server used. You can however run both servers at the same time or change your default server.
-The default server will be started automatically when the workspace is started
+You may also run the PHP Development server manually via the command `php artisan serve`.
-You can toggle any server on and off from any terminal window by running the relevant command:
+The default server will be started automatically when the workspace is started.
+
+You can toggle any server on and off from any terminal window by running the relevant command. These commands will also dynamically kill the log monitor process for that server:
- Apache: `start_apache` or `stop_apache`
+
- PHP built-in development server: `start_php_dev` or `stop_php_dev`
+### Changing the default server
+Change the value of `default_server` in the `development` section of `starter.ini` to either `php` or `apache`
-**Changing the default server**
+### Changing the apache log monitor binary
-Change the value of `default_server` in the `development` section of `starter.ini` to either `php` or `apache`
+The system will show apache logs with either `multitail` or a colorized tail (using `grc`).
+Change the value of `apache_log_monitor` in the `development` section of `starter.ini` to either `tail` or `multitail`
+Note: `multitail` is prone to [issues](https://github.com/apolopena/gitpod-laravel8-starter/issues/53) depending on the size of the terminal it is launched in so the default is a colorized `tail`.
-**Running more than one server at a time**
+### Running more than one server at a time
You may start and stop multiple servers.
-Lets say you have the Apache server running and you want to run the PHP development server at the same time just run this command:
+If you have the Apache server running and you want to run the PHP development server at the same time just run this command:
`start_server php`
-And now the PHP server will be running is parallel.
+Now the PHP server will be running in parallel.
+Note: Laravel requires a url to be set in the `.env` file in the project root. This is done for you automatically when the workspace is initialized. The url set in the `.env` file contains the server port so if you want to properly serve Laravel pages from a server other than the default server you initialized the project with then will need to change the values for APP_URL and ASSET_URL accordingly.
+
## Debugging
Debugging must be enabled before breakpoints can be hit and will last for an hour before the debug session is disabled automatically.
-When debugging is enabled or disabled the preview browser will reload the index page. When debugging is enabled *each* subsequent request can be debugged for an hour or until debugging is disabled.
-
-This system uses port `9009` for the debugging. A launch configuration file is included (`/.theia/launch.json`).
-
+When debugging is enabled or disabled, the preview browser will reload the index page. When debugging is enabled, *each* subsequent request can be debugged for an hour or until debugging is disabled.
+This system uses port `9009` for the debugging. A launch configuration file is included in `.theia/launch.json`.
-**The default development sever**
+### The default development server
To enable a debugging session on the default development server run `debug-on` in a Gitpod terminal.
To disable a debugging session on the default development server run `debug-off` in a Gitpod terminal.
-
-
-**Specific development servers**
+### Specific development servers
If you are running more than one development server at the same time or you are not running the default development server then you can toggle the debugging session for a specific server:
- `debug on apache` or `debug_on php`
-
+ `debug-on apache` or `debug-on php`
+### Setting breakpoints
-**Setting breakpoints**
-
-- Once the preview browser is open, You can set a breakpoint in the Gitpod IDE by clicking in the gutter next to the line of code you want in any `php` file in the `public` folder (or deeper)
+- Once the preview browser is open, You can set a breakpoint in the Gitpod IDE by clicking in the gutter next to the line of code you want in any PHP file in the `public` folder (or deeper)
- Then in the Gitpod IDE in the browser:
- 2. Hit the debug icon in the left side panel to open the Debug panel.
- 3. Choose "Listen for XDebug" from the dropdown list.
- 4. Hit the green play button (you should see the status "RUNNING" in the Threads panel)
- 5. Refresh the preview browser and you should now hit your breakpoint.
-
-All debugging is subject to server timeout, refreshing the preview browser will make this go away.
-
-
+ 1. Hit the debug icon in the left side panel to open the Debug panel.
+ 2. Choose "Listen for XDebug" from the dropdown list.
+ 3. Hit the green play button (you should see the status "RUNNING" in the Threads panel)
+ 4. Refresh the preview browser and you should now hit your breakpoint in the IDE.
-**Debugging Blade templates**
+All debugging is subject to server timeout, just refreshing preview browser if this happens.
+### Debugging Blade templates
You may also debug blade templates by placing the following snippet above where you want to inspect the blade directive.
@@ -235,44 +273,121 @@ You may also debug blade templates by placing the following snippet above where
Save the file and refresh the preview browser when the debugger is in the IDE.
-If all else fails stop the debugger, launch the "Listen for Xdebug" launch configuration again and refresh the preview browser.
-This will open a temporary `php` file that has all the blade directives converted to `php` tags, you may set additional breakpoints in this code as well. Do not edit the code in these temporary files as it they be disposed and are only derived for that debugging session.
+This will open a temporary PHP file that has all the blade directives converted to `php` tags, you may set additional breakpoints in this code as well. Do not edit the code in these temporary files as it they be disposed at any time and are only derived for that debugging session.
+If you are having trouble, launch the "Listen for Xdebug" launch configuration again and refresh the preview browser.
+
-## Tailing the xdebug log
+## Tailing the Xdebug Log
-To tail the xdebug log
+ 1. Open a new terminal in gitpod
+ 2. Run the command: `tail -f /var/log/xdebug.log`
- 1. Open a new terminal in gitpod
- 2. Run the command: `tail -f /var/log/xdebug.log`
+
+## phpMyAdmin ##
+phpMyAdmin is a tool that handles MySQL administration over the web. This tool is very powerful and can be essential when developing MySQL powered systems especially in the cloud. For more information on what phpMyAdmin can do, check out the [official documentation](https://www.phpmyadmin.net/docs/), the [user guide](https://docs.phpmyadmin.net/en/latest/user.html) or just dabble around on the [demo server](https://www.phpmyadmin.net/try/).
-## Auto Generating a CHANGELOG.md
+### Installing phpMyAdmin
+phpMyAdmin is installed automatically by default. A phpMyAdmin installation directive is available in `starter.ini` that allows you to omit the installation if you like. The phpMyAdmin installation is done in the Docker image which makes it prone to caching so special steps may need to be taken in order to get the phpmyadmin installation directive in `starter.ini` to work properly. See [here](https://github.com/apolopena/gitpod-laravel8-starter/issues/28) for more details.
-Keeping track of your changes and releases is easy now.
+### Security Concerns
-There is an option in `starter-ini` to install [github-changelog-generator] (https://github.com/github-changelog-generator/github-changelog-generator).
+phpMyAdmin also introduces some extra security concerns that should be addressed immediately after initialization of a new Gitpod workspace. If you have installed phpMyAdmin using install directive starter.ini then by default two MySQL accounts are created using default passwords stored in version control:
-This option is on by default, additional settings for this option can be found in `starter.ini`.
+ - **pmasu**: This is the superuser account that a developer can use to log into phpMyAdmin in order to administer any MySQL database.
+ - The default password for the user **pmasu** is: ***123456***
+- **pma**: This is the controluser that the phpMyAdmin uses internally to manage it's advanced storage features which are enabled by default. This user can only administer the `phpmyadmin` database and should not be used by anyone.
+ - The default password the user **pma** is: ***pmapass***
+
+
+
+### Securing phpMyAdmin
-You can generate a CHANGELOG.md at any time by running the command:
+At a minimum the default passwords that phpMyAdmin uses to administer the MySQL databases should be changed right after a Gitpod workspace has been created for the first time. An `update_phpmyadmin_pws` alias has been provided that automagically changes the default passwords.
+
+To change the phpMyAdmin MySQL passwords using the `update_phpmyadmin_pws` alias, follow these steps:
+ 1. Create a file in the root of the project named `.starter.env`
+ 2. Copy and paste all the keys containing `PHPMYADMIN` from `.starter.env.example` to `.starter.env`
+ 3. In .starter.ini, set password values for the `PHPMYADMIN` keys and save the file.
+ 4. In a terminal run the alias: `update_phpmyadmin_pws`
+
+
+## Generating a CHANGELOG.md Using github-changelog-generator
+
+Keeping track of your changes and releases can easily be automated.
+There is an option in `starter-ini` to install [`github-changelog-generator`](https://github.com/github-changelog-generator/github-changelog-generator).
+This option is on by default, additional settings for this option can be found in `starter.ini`.
+You can generate a `CHANGELOG.md` by running the command:
`rake changelog`
+Currently generating a changelog can only be done when the workspace is built for the first time. See [here](https://github.com/apolopena/gitpod-laravel8-starter/issues/57) for more details
+See [github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator) for more information on what you can do with it.
+Note: any options you may need to pass in can be passed in through the rake command: `rake changelog`.
+
+### Setting up an Access Token for github-changelog-generator
+
+GitHub limits API calls unless using an [access token](https://github.com/settings/tokens/).
+`github-changelog-generator` uses the GitHub API to generate a `CHANGELOG.md` and will quickly max out of API calls if you try to generate the `CHANGELOG.md` more than a few times in a certain period of time.
+It is recommended that you setup an access token from your GitHub account and then set that access token in an environment variable via your Gitpod dashboard. This way any project you like can generate a `CHANGELOG.md` as many times as it likes without error.
+
+1. You can generate an access token [here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token). If the repository is public you do not need to grant any special privileges, just generate the token and copy it to your clipboard. Otherwise if the repository is private you need to grant it 'repo' privileges.
+2. Once you have the github access token copied to your clipboard, in your gitpod account go to settings in the Environment Variables section click the "Add Variable" button.
+3. For the 'name' field value type in `CHANGELOG_GITHUB_TOKEN`
+4. For the 'value' field paste in your github access token
+5. For the 'Organization/Repository' field you may leave it as it or type in GITHUBUSERNAME/* where GITHUBUSERNAME is the user name of your github account. This will allow you to use the github-changelog-generator as many times as you like for any of your repositories.
+6. Restart or create a new workspace and you will now be able to use `github-changelog-generator` via the `rake changelog` command as many times as you like.
-See [github-changelog-generator] (https://github.com/github-changelog-generator/github-changelog-generator) for more details on what you can do with it.
+Important Note: If you do not generate an access token for `github-changelog-generator` and if you do not cancel the error that results when you exceed your Github API calls when using it you could potentially run out of space for your github workspaces and not be able to create any any new workspace or open any existing ones until you delete the offending workspace(s).
+
+## Project Specific Bash Code for Gitpod
-## Emoji-log
+Bash code that should be run when your Gitpod workspace is created for the first time should be put in the file:
+`bash/init-project.sh`
+This file contains some basic scaffolding and examples that you can use in your project if you like.
-[Emoji-log](https://github.com/ahmadawais/Emoji-Log) git aliases are included. You them as you like from the command line.
+
+## Ruby Gems
+Currently until gitpod fixes the [issue](https://github.com/apolopena/gitpod-laravel8-starter/issues/57) of ruby gems not persisting across workspace restarts, you can only use rake commands when the workspace is created for the first time.
+
+
+
+## Emoji-log and Gitmoji
+
+A compilation of git aliases from [Emoji-log](https://github.com/ahmadawais/Emoji-Log) and [Gitmoji](https://gitmoji.dev/) are included, use them as you like from the command line. There is also a separate set of emoji based git aliases that will commit the files with a message and push them to the repository *without* adding the files. Use these aliases for dealing with groups of files that need different commit messages but still need to use to Emoji-log and or Gitmoji standards. You can get a list of all the emoji based git alias with the command: `git a`
+
+
## Local Development Outside of Gitpod ##
-For now this will be something you need to figure out. Eventually some guidelines for how to do that with vscode will be added here.
+For now this will be something you need to figure out. Eventually some guidelines for how to do that will be added here.
+
+
+
+## Deployment Outside of Gitpod
+
+For now this will be something you need to figure out. Eventually some guidelines for how to do that will be added here.
+
+
+
+## Gitpod Caveats
+Gitpod is an amazing and dynamic platform however at times, and especially during it's peak hours, latency can affect the workspace. Here are a few symptoms that you can try to remedy by recreating the workspace or waiting for some time before trying to open or create a workspace. This section will be updated as Gitpod progresses.
+ - **Symptom**: Workspace loads, IDE displays, however one or more terminals are blank.
+ - **Possible Fix**: Delete the workspace in your Gitpod dashboard and then [recreate the workspace](#creating-a-new-workspace-in-gitpod-from-your-new-github-project-repository).
+ - **Symptom**: Workspace loads, IDE displays, however no ports become available and or the spinner stays spinning in the terminal even after a couple of minutes.
+ - **Possible Fix**: Refresh the browser
+
+
+## Thanks
+
+To the communities of:
-*Thanks to the gitpod community and xdebug!
\ No newline at end of file
+- Gitpod
+- Laravel
+- Xdebug
\ No newline at end of file
diff --git a/bash/.bash_aliases b/bash/.bash_aliases
new file mode 100644
index 00000000..6ed66ecb
--- /dev/null
+++ b/bash/.bash_aliases
@@ -0,0 +1,9 @@
+# This file is sourced into ~/.bashrc
+# Add any alias you would like here
+
+# Updates all passwords related to phpmyadmin from values set in .starter.env
+# Requires .starter.env to have all phpmyadmin related keys set with values
+# Empty string value will break the script
+# See .starter.env.example for the required phpmyadmin keys
+alias update_pma_pws="bash $GITPOD_REPO_ROOT/bash/change-passwords.sh phpmyadmin"
+alias help_update_pma_pws="cat bash/snippets/messages/help-update-pma-pws.txt"
\ No newline at end of file
diff --git a/bash/before-tasks.sh b/bash/before-tasks.sh
index 3edc77f6..22267e67 100644
--- a/bash/before-tasks.sh
+++ b/bash/before-tasks.sh
@@ -25,10 +25,10 @@ log_silent () {
# Some rake tasks are dynamic and depend on the configuration in starter.ini
if [ "$(bash bash/utils.sh parse_ini_value starter.ini github-changelog-generator install)" ]; then
msg="Writing rake tasks"
- log "$msg..." &&
+ log_silent "$msg..." &&
bash bash/init-rake-tasks.sh
if [ $? == 0 ]; then
- log "SUCCESS: $msg"
+ log_silent "SUCCESS: $msg"
else
log "ERROR: $msg" -e
fi
@@ -36,25 +36,28 @@ fi
# Aliases for git
-msg="\ngit aliases have been written"
+msg="git aliases have been written"
bash bash/utils.sh add_file_to_file_after \\[alias\\] bash/snippets/emoji-log ~/.gitconfig &&
bash bash/utils.sh add_file_to_file_after \\[alias\\] bash/snippets/git-aliases ~/.gitconfig &&
-log "$msg" &&
-log "\ntry: git a or: git aliases\nto see what is available.\n"
+log_silent "$msg" &&
+log_silent "try: git a or: git aliases to see what is available."
# grc color configuration for apache logs
-msg="Creating grc color configuration file for apache logs: ~/apache-log-colors.conf"
-log "$msg..." &&
+msg="Creating grc color configuration file for apache logs in ~/apache-log-colors.conf"
+log_silent "$msg..." &&
cat bash/snippets/grc/apache-log-colors > ~/apache-log-colors.conf
if [ $? == 0 ]; then
- log "SUCCESS: $msg"
+ log_silent "SUCCESS: $msg"
else
log "ERROR: $msg" -e
fi
-# Keep this at the bottom of the file
-# Restores files marked as persistant
-# See persist_file in bash/helpers.sh
+# Restore files marked as persistant such
+# as workspace-init.log
+# See persist_file in bash/helpers.sh for how to system works
+# Keep this block at the bottom of the file so that any logging from this
+# script is only written to file upon initialization! Otherwise workspace-init.log
+# will get written to from this script upon every wrokspace restart.
if [ $(bash bash/helpers.sh is_inited) == 1 ]; then
bash bash/helpers.sh restore_persistent_files $GITPOD_REPO_ROOT
fi
\ No newline at end of file
diff --git a/bash/change-passwords.sh b/bash/change-passwords.sh
new file mode 100644
index 00000000..c0f8460f
--- /dev/null
+++ b/bash/change-passwords.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+#
+# change-passwords.sh
+#
+# Description:
+# changes passwords for phpmyadmin from the defaults in version control to the values set in .starter.env
+# Author: Apolo Pena
+#
+# NOTE:
+# This script should be always run at least once by the user as an mandatory additional layer of security
+# This script requires the file .starter.env to exist along will all the key value pairs as set
+# in example.starter.ini
+
+# Load spinner
+. bash/third-party/spinner.sh
+
+phpmyadmin() {
+ # Keep keys in sequence. Add new keys to the end of the array
+ local keys=(PHPMYADMIN_SUPERUSER_PW PHPMYADMIN_CONTROLUSER_PW)
+
+ local name="change-passwords.sh phpmyadmin"
+ local err="$name ERROR:"
+ local config_file="public/phpmyadmin/config.inc.php"
+ local all_zeros='^0$|^0*0$'
+ local exit_codes
+ local values
+
+ for key in ${keys[@]}; do
+ local value="$(bash bash/helpers.sh get_starter_env_val $key)"
+ values+=("$(bash bash/helpers.sh get_starter_env_val $key)")
+ local code="$?"
+ exit_codes+=$code
+ # show error message of called function
+ [ $code != 0 ] && echo "$value"
+ done
+
+ if [[ ! $(echo ${exit_codes[@]} | tr -d '[:space:]') =~ $all_zeros ]]; then
+ echo "$err retrieving values, no passwords were changed."
+ exit 1
+ fi
+
+ # Values have been set and there are no errors so far so change passwords
+ i=0
+ for key in ${keys[@]}; do
+ case $key in
+ "${keys[0]}")
+ msg="Changing password for phpmyadmin user 'pmasu' to the value found in .starter.env"
+ start_spinner "$msg"
+ mysql -e "ALTER USER 'pmasu'@'%' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;"
+ stop_spinner $?
+ ;;
+ "${keys[1]}")
+ msg="Changing password for phpmyadmin user 'pma' to the value found in .starter.env"
+ start_spinner "$msg"
+ mysql -e "ALTER USER 'pma'@'localhost' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;"
+ err_code=$?
+ stop_spinner $err_code
+ if [ $err_code == 0 ]; then
+ msg="Updating control user password in $config_file"
+ line="\$cfg['Servers'][\$i]['controlpass'] ="
+ _edit="\$cfg['Servers'][\$i]['controlpass'] = '${values[$i]}';"
+ start_spinner "$msg"
+ # Match the line where the password for the controluser is set
+ line_num=$(awk '/^\$cfg.*'controlpass'.*=.*;$/ {print FNR}' $config_file)
+ if [ -z $line_num ]; then
+ stop_spinner 1
+ echo "ERROR: No line found beginning with: $line \n\tin the file: $config_file"
+ echo "You will need to manually update the control user password in $config_file"
+ else
+ sed -i "$line_num c\\$_edit" $config_file
+ err_code=$?
+ stop_spinner $err_code
+ unset _edit
+ [ $err_code == 0 ] &&
+ echo -e "\e[38;5;171mPROCESS COMPLETE\e[0m" &&
+ echo -e "\e[1;33mCheck the console output for any possible failures.\e[0m" &&
+ echo -en "\e[1;36m" &&
+ echo "If you are logged into phpmyadmin, log out and log back in." &&
+ echo "For additional security you can delete .starter.env" &&
+ echo "Just make sure you remember your passwords from that file." &&
+ echo "If you ever loose your passwords you may always set them again" &&
+ echo "using this script and new values set in .starter.env" &&
+ echo -e "\e[0m"
+ fi
+ fi
+ ;;
+ *)
+ echo "$err unidentified key $value"
+ ;;
+ esac
+ ((i++))
+ done
+}
+
+# Call functions from this script gracefully
+if declare -f "$1" > /dev/null
+then
+ # call arguments verbatim
+ "$@"
+else
+ echo "utils.sh: '$1' is not a known function name." >&2
+ exit 1
+fi
+
+#echo -e "$(change_phpmyadmin_passwords)"
diff --git a/bash/helpers.sh b/bash/helpers.sh
index 0b52b3c0..697db3e3 100644
--- a/bash/helpers.sh
+++ b/bash/helpers.sh
@@ -13,7 +13,7 @@
#
version () {
- echo "helpers.sh version 0.0.3"
+ echo "helpers.sh version 0.0.6"
}
# start_server
@@ -117,7 +117,68 @@ show_first_run_summary() {
echo ''
cat $init_log
echo -en "\e[0m"
- echo -en "\n\e[38;5;171mALL DONE 🚀\e[0m\n"
+ [ -d 'public/phpmyadmin' ] &&
+ echo -en "\e[38;5;208m" &&
+ cat bash/snippets/messages/phpmyadmin-security.txt &&
+ echo -e "\e[0m"
+ echo -en "\e\n[38;5;171mALL DONE 🚀\e[0m\n"
+}
+
+# get_starter_env_val
+# Description:
+# Outputs a value for a key ($1) set in .starter.env
+# Verbose error reporting for various edge cases
+# and /var/log/workspace-init.log
+#
+# Usage (output will either be the value of the key or an error message):
+# value="$(get_starter_env_value PHPMYADMIN_CONTROL_PW)"
+# echo $value
+get_starter_env_val() {
+ local err='get_starter_env_val ERROR:'
+ local file='.starter.env'
+ local value
+ value="$(bash bash/utils.sh get_env_value $1 $file)"
+ case "$?" in
+ '0')
+ echo $value
+ ;;
+
+ '3')
+ echo "$err no file: $file"
+ exit 1
+ ;;
+
+ '4')
+ echo -e "$err no var '$1' found in file $file"
+ exit 1
+ ;;
+
+ '5')
+ echo "$err no value found for '$1' found in file $file"
+ exit 1
+ ;;
+
+ *)
+ echo "$err unidentified error $?"
+ exit 1
+ ;;
+ esac
+}
+
+get_default_server_port() {
+ local server=$(bash bash/utils.sh parse_ini_value starter.ini development default_server) ;
+ server=$(echo $server | tr '[:upper:]' '[:lower:]')
+ case "$server" in
+ 'php')
+ echo 8000
+ ;;
+ 'apache')
+ echo 8001
+ ;;
+ *)
+ # Ignore invalid server types
+ ;;
+ esac
}
# Begin: persistance hacks
@@ -161,8 +222,113 @@ is_inited() {
}
# End: persistance hacks
+# Begin: installation information API
+# parses starter.ini for installation for the install key of a section ($1)
+get_install() {
+ echo "$(bash bash/utils.sh parse_ini_value starter.ini $1 install)"
+}
+# parses starter.ini and echos a string showing installtaion information for any installs key in the list.
+# The install key list is set in this function. The install key list is order specific.
+# phpmyadmin needs to be first, the next three installs are the frontend scaffolding installs.
+# You can add any additional installs to the end of this string delimited by a space character.
+get_installs() {
+ # Space delimited list of installs to check
+ # starter.ini must have a section named by the string and a key named install
+ # So not change the order of installs in this string, just add more to the end if needed
+ local installs='phpmyadmin react vue bootstrap'
+ for i in $installs; do
+ data+=$i:$(get_install $i)
+ done
+ echo $data
+}
+# parses starter.ini for installation information
+# Echos 1 if any install key in list (see installs varaible in get_install function) in starter.ini
+# has a value of 1.
+# Echos 0 if no keys in the list have a value of 1
+has_installs() {
+ local result=$(echo $(get_installs) | grep -oP '\d' | tr -d '[:space:]')
+ local pattern='.*[1-9].*'
+ if [[ $result =~ $pattern ]]; then
+ echo 1
+ else
+ echo 0
+ fi
+}
+
+# parses starter.ini for installation information
+# Echos 1 if the install key for phpmyadmin is set to 1 and no frontend scaffolding keys are set to 1
+# There are three possible frontend scaffolding keys: react, vue and bootstrap
+# Echos 0 if the install key for phpmyadmin is not set to 1 or if it is set to 0 but any frontend
+# scaffolding key is set to 1
+has_only_phpmyadmin_install() {
+ local result=$(echo $(get_installs) | grep -oP '\d' | tr -d '[:space:]')
+ local all_zeros='^0$|^0*0$'
+ # if the string starts with a 1 phpmyadmin is installed
+ if [[ $result =~ ^1 ]]; then
+ # trim the first character from the string
+ local installs="${result:1}"
+ # if the trimmed string is all zeros
+ if [[ $installs =~ $all_zeros ]]; then
+ # only phpmyadmin is installed
+ echo 1
+ else
+ # phpmyadmin is not the only install
+ echo 0
+ fi
+ else
+ # phpmyadmin is not the only install
+ echo 0
+ fi
+}
+
+# parses starter.ini for installation information
+# Echos 1 if the install key for phpmyadmin is set to 0 and any frontend scaffolding key is set to 1
+# There are three possible frontend scaffolding keys: react, vue and bootstrap
+# Echos 0 if the install key for phpmyadmin is set to 1 and any frontend scaffolding key is set to 1
+has_only_frontend_scaffolding_install() {
+ local result=$(echo $(get_installs) | grep -oP '\d' | tr -d '[:space:]')
+ local all_zeros='^0$|^0*0$'
+ # if the string starts with a 0 phpmyadmin is not installed
+ if [[ $result =~ ^0 ]]; then
+ # trim the first character from the string
+ local installs="${result:1}"
+ # Trim the next three characters in the string (there are only three possible front end scaffolding)
+ # and gnore any other installs besides front end scaffolding and phpmyadmin (the rest of the string)
+ local scaff_installs=$(echo ${installs:0:3})
+ # if the trimmed string is all zeros
+ if [[ $scaff_installs =~ $all_zeros ]]; then
+ # no frontend scaffolding is installed
+ echo 0
+ else
+ # only frontend scaffolding is installed
+ echo 1
+ fi
+ else
+ # More than frontend scaffolding is installed
+ echo 0
+ fi
+}
+
+# parses starter.ini for installation information
+# Echos 1 if the install key either react, vue or bootrap is set to 1
+# There are three possible frontend scaffolding keys: react, vue and bootstrap
+# Echos 0 if neither react, vue or bootrap has an install key value of 1
+has_frontend_scaffolding_install() {
+ local result=$(echo $(get_installs) | grep -oP '\d' | tr -d '[:space:]')
+ local all_zeros='^0$|^0*0$'
+ # Trim the first character from the string (this is the phpmyadmin value)
+ local installs="${result:1}"
+ # Trim the next three characters in the string (there are only three possible front end scaffolding)
+ local scaff_installs=$(echo ${installs:0:3})
+ if [[ $scaff_installs =~ $all_zeros ]]; then
+ echo 0
+ else
+ echo 1
+ fi
+}
+# End: installation information API
# Call functions from this script gracefully
if declare -f "$1" > /dev/null
diff --git a/bash/init-complete.sh b/bash/init-complete.sh
index c224368c..f6d504bf 100644
--- a/bash/init-complete.sh
+++ b/bash/init-complete.sh
@@ -4,7 +4,7 @@
# Summarize results
bash bash/helpers.sh show_first_run_summary
-echo -e "\e[38;5;194mIf everything looks good in the above results then push the newly created\n project files to your git repo and get started coding your project\e[0m"
+echo -e "\e[38;5;194mIf everything looks good in the above results then push any new\nproject files to your git repository. Your project is ready to code.\e[0m"
# Persist the workspace-init.log since the .gitpod.Dockerfile will wipe it out and it wont come back after the first run
bash bash/helpers.sh persist_file /var/log/workspace-init.log
diff --git a/bash/init-gitpod.sh b/bash/init-gitpod.sh
index 98ac842f..78775a0d 100644
--- a/bash/init-gitpod.sh
+++ b/bash/init-gitpod.sh
@@ -30,22 +30,45 @@ stop_spinner $?
# Move Laravel project files if they are not already in version control
if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then
- msg="\nrsync Laravel project from ~/temp-app to $GITPOD_REPO_ROOT"
+ msg="\nrsync Laravel 8 scaffolding from /home/gitpod/laravel8-starter to $GITPOD_REPO_ROOT"
# TODO: replace spinner with a real progress bar for coreutils
log_silent "$msg..." && start_spinner "$msg..."
shopt -s dotglob
- rsync -rlptgoD --ignore-existing ~/test-app/ $GITPOD_REPO_ROOT
+ grc -c bash/snippets/grc/rsync-stats \
+ rsync -rlptgoD --ignore-existing --stats --human-readable /home/gitpod/laravel8-starter/ $GITPOD_REPO_ROOT
err_code=$?
if [ $err_code != 0 ]; then
stop_spinner $err_code
- log "ERROR: Failed to rsync Laravel project from ~/temp-app to $GITPOD_REPO_ROOT" -e
+ log "ERROR: $msg" -e
else
stop_spinner $err_code
- log "SUCCESS: rsync Laravel project from ~/temp-app to $GITPOD_REPO_ROOT"
+ log_silent "SUCCESS: $msg"
fi
# BEGIN: parse configurations
+ # BEGIN Laravel .env injection
+ if [ -e .env ]; then
+ msg="Injecting Laravel .env file with APP_URL and ASSET_URL"
+ start_spinner "$msg"
+ default_server_port=$(bash bash/helpers.sh get_default_server_port)
+ url=$(gp url $default_server_port)
+ sed -i'' "s#^APP_URL=http://localhost*#APP_URL=$url\nASSET_URL=$url#g" .env
+ err_code=$?
+ if [ $err_code != 0 ]; then
+ stop_spinner 1
+ log "ERROR: Could not inject Larvel .env file with the url $url" -e
+ else
+ stop_spinner $err_code
+ log_silent "SUCCESS: Laravel .env APP_URL and ASSET_URL was set to $url"
+ log_silent " You should check .env to make sure the values are set correctly."
+ log_silent " If you change the server then the port number will need to be"
+ log_silent " changed in .env for APP_URL and ASSET_URL"
+ fi
+ else
+ log 'ERROR: no Laravel .env file to inject'
+ fi
+ # BEGIN Laravel .env injection
# Configure .editorconfig
if [ -e .editorconfig ]; then
ec_type=$(bash bash/utils.sh parse_ini_value starter.ini .editorconfig type)
@@ -61,68 +84,26 @@ if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then
;;
esac
fi
-
- # Laravel .env
- [ -e .env ] && url=$(gp url 8000); sed -i'' "s#^APP_URL=http://localhost*#APP_URL=$url\nASSET_URL=$url#g" .env
# END: parse configurations
# Create laravel database if it does not exist
# TODO: think more about making this dynamic as per .env
__laravel_db_exists=$(mysqlshow 2>/dev/null | grep laravel >/dev/null 2>&1 && echo "1" || echo "0")
if [ $__laravel_db_exists == 0 ]; then
- __laravel_db_msg="laravel database did not exist in mysql. Creating database: laravel"
- log_silent "$__laravel_db_msg..." && start_spinner "$__laravel_db_msg..."
+ msg="Creating database: laravel"
+ log_silent "$msg..." && start_spinner "$msg"
mysql -e "CREATE DATABASE laravel;"
err_code=$?
if [ $err_code != 0 ]; then
stop_spinner $err_code
- log "ERROR: Failed to move createe mysql database: laravel" -e
+ log "ERROR: $msg" -e
else
stop_spinner $err_code
- log "SUCCESS: created mysql database: laravel"
+ log_silent "SUCCESS: $msg"
fi
fi
- # Install node packages if needed, in case the Laravel Ui front end is already in version control
- if [[ -f "package.json" && ! -d "node_modules" ]]; then
- log "Found a package.json but there are no node modules installed"
- log " --> Installing node packages..."
- yarn install
- log " --> Node packages installed"
- log " --> Running Laravel Mix..."
- yarn run dev
- log " --> Running of Laravel Mix complete"
- fi
-
+
# BEGIN: Optional configurations
- # Super user account for phpmyadmin
- installed_phpmyadmin=$(. bash/utils.sh parse_ini_value starter.ini phpmyadmin install)
- if [ "$installed_phpmyadmin" == 1 ]; then
- msg="Creating phpmyadmin superuser: pmasu"
- log_silent "$msg" && start_spinner "$msg"
- mysql -e "CREATE USER 'pmasu'@'%' IDENTIFIED BY '123456';"
- mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'pmasu'@'%';"
- err_code=$?
- if [ $err_code != 0 ]; then
- stop_spinner $err_code
- log "ERROR: failed to create phpmyadmin superuser: pmasu" -e
- else
- stop_spinner $err_code
- fi
- if [ ! -d 'public/phpmyadmin/node_modules' ]; then
- log "phpmyadmin node modules have not yet been installed, installing now..."
- cd public/phpmyadmin && yarn install && cd ../../
- if [ $? == 0 ]; then
- __pmaurl=$(gp url 8001)/phpmyadmin
- log "phpmyadmin node modules installed."
- log "To login to phpmyadmin:"
- log " --> 1. Make sure you are serving it with apache"
- log " --> 2. In the browser go to $__pmaurl"
- log " --> 3. You should be able to login here using the default account. user: pmasu, pw: 123456"
- else
- log "ERROR: installing phpmyadmin node modules. Try installing them manually." -e
- fi
- fi
- fi
# Install https://github.com/github-changelog-generator/github-changelog-generator
installed_changelog_gen=$(bash bash/utils.sh parse_ini_value starter.ini github-changelog-generator install)
if [ "$installed_changelog_gen" == 1 ]; then
@@ -133,14 +114,36 @@ if [ ! -d "$GITPOD_REPO_ROOT/vendor" ]; then
fi
# END: Optional configurations
+ # Install node packages and run laravel mix blindly here since at this stage there is no viable
+ # hook for when laravel/ui frontend scaffolding (react, vue or bootstrap) is in version control but the
+ # workspace is initializing for the first time. This is the only way we can establish a hook
+ # for init-optional-scaffolding.sh to determine if it should bypass the php artisan ui command
+ # since the hook that init-optional-scaffolding.sh uses is to look for a directory in node_modules
+ # named react, vue or bootstrap. Without this hook project code such ass app.js gets overwitten.
+ if [[ -f "package.json" && ! -d "node_modules" ]]; then
+ msg="Installing node modules"
+ log "$msg..."
+ yarn install
+ err_code=$?
+ if [ $err_code != 0 ]; then
+ log "ERROR $?: $msg" -e
+ else
+ log "SUCCESS: $msg"
+ fi
+ log " --> Running Laravel Mix..."
+ npm run dev
+ log " --> Running of Laravel Mix complete"
+ fi
+
# Move and merge necessary files, then cleanup
- mv ~/test-app/README.md $GITPOD_REPO_ROOT/README_LARAVEL.md
- rm -rf ~/test-app
+ mv /home/gitpod/laravel8-starter/README.md $GITPOD_REPO_ROOT/README_LARAVEL.md
+ rm -rf /home/gitpod/laravel8-starter
+ [ $? == 0 ] && log_silent "CLEANUP SUCCESS: removed /home/gitpod/laravel8-starter"
fi
# END: Bootstrap Laravel scaffolding
# Messages for github_changelog_generator
[ "$installed_changelog_gen" == 1 ] &&
-log "You may auto generate a CHANGELOG.md from github commits by running the command:\nrake changelog [...options]\n" &&
-log "See starter.ini (github_changelog_generator section) for configurable options" &&
-log "For a full list of options see the github-changelog-generator repository on github"
+log_silent "You may auto generate a CHANGELOG.md from github commits by running the command:\nrake changelog [...options]" &&
+log_silent "See starter.ini (github_changelog_generator section) for configurable options" &&
+log_silent "For a full list of options see the github-changelog-generator repository on github"
diff --git a/bash/init-optional-scaffolding.sh b/bash/init-optional-scaffolding.sh
index 63d81fcf..f748ee1c 100644
--- a/bash/init-optional-scaffolding.sh
+++ b/bash/init-optional-scaffolding.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# install-optional-scaffoliding.sh
+# init-optional-scaffoliding.sh
# Description:
# Installs various packages according to the configuration set in starter.ini
@@ -22,31 +22,35 @@ log_silent () {
fi
}
+# regexp pattern for checking an array of exit codes
+all_zeros_reg='^0$|^0*0$'
+
+# Load spinner
+. bash/third-party/spinner.sh
+
parse="bash bash/utils.sh parse_ini_value starter.ini"
install_react=$(eval $parse react install)
install_vue=$(eval $parse vue install)
install_bootstrap=$(eval $parse bootstrap install)
+# BEGIN: optional frontend scaffolding installations
# BEGIN: Install Laravel ui if needed
-if [[ $install_react == 1 || $install_bootstrap == 1 ]]; then
+has_frontend_scaffolding_install=$(bash bash/helpers.sh has_frontend_scaffolding_install)
+if [[ $has_frontend_scaffolding_install == 1 ]]; then
log "Optional installations that require laravel/ui scaffolding were found"
-
# Assume we are using composer 2 or higher, check if the laravel/ui package has already been installed
composer show | grep laravel/ui >/dev/null && __ui=1 || __ui=0
-
if [ "$__ui" == 1 ]; then
log "However it appears that laravel/ui has already been installed, skipping this installation."
else
- log "Installing laravel/ui scaffolding"
+ log "Installing laravel/ui scaffolding via Composer"
composer require laravel/ui:^3.2.0
err_code=$?
if [ $err_code == 0 ]; then
log "SUCCESS: laravel/ui scaffolding installed"
- log "Compiling fresh scaffolding and running Laravel Mix"
- yarn install && yarn run dev
else
- log "ERROR $err_code: There was a problem installing laravel/ui" -e
+ log "ERROR $err_code: There was a problem installing laravel/ui via Composer" -e
fi
fi
fi
@@ -63,7 +67,7 @@ if [ "$install_react" == 1 ]; then
if [ "$__installed" == 1 ]; then
log "However it appears that React/React DOM has already been installed, skipping this installation."
else
- log "Installing React and React DOM"
+ log "Installing React and React DOM$auth_msg ..."
if [ "$auth" == 1 ]; then
php artisan ui react --auth
else
@@ -71,18 +75,18 @@ if [ "$install_react" == 1 ]; then
fi
err_code=$?
if [ $err_code == 0 ]; then
- log "SUCCESS: React and React DOM$version_msg$auth_msg have been installed"
- log "Compiling fresh scaffolding and running Laravel Mix"
- yarn install && yarn run dev && sleep 1 && yarn run dev
+ log "SUCCESS: React and React DOM$auth_msg have been installed"
+ log " --> Installing node modules and running Laravel Mix"
+ yarn install && npm run dev && sleep 1 && npm run dev
if [ ! -z "$version" ]; then
- log "Setting react and react-dom to$version_msg"
+ log "Upgrading react and react-dom to$version_msg"
# TODO: validate semver and valid version for the package so users cant pass in junk
yarn upgrade react@$version react-dom@$version
fi
[ "$install_bootstrap" == 1 ] && log "Bootstrap install directive found but ignored. Already installed"
[ "$install_vue" == 1 ] && log "Vue install directive found but ignored. The install of react superceded this"
else
- log "ERROR $err_code: There was a problem installing React/React DOM$version_msg$auth_msg" -e
+ log "ERROR $err_code: There was a problem installing React/React DOM$auth_msg" -e
fi
fi
fi
@@ -99,7 +103,7 @@ if [[ "$install_vue" == 1 && "$install_react" == 0 ]]; then
if [ "$__installed" == 1 ]; then
log "However it appears that Vue has already been installed, skipping this installation."
else
- log "Installing Vue..."
+ log "Installing vue$auth_msg ..."
if [ "$auth" == 1 ]; then
php artisan ui vue --auth
else
@@ -107,26 +111,23 @@ if [[ "$install_vue" == 1 && "$install_react" == 0 ]]; then
fi
err_code=$?
if [ $err_code == 0 ]; then
- log "SUCCESS: Vue$version_msg$auth_msg has been installed"
- log "Compiling fresh scaffolding and running Laravel Mix"
- yarn install && yarn run dev && sleep 1 && yarn run dev
+ log "SUCCESS: Vue$auth_msg has been installed"
+ log " --> Installing node modules and running Laravel Mix"
+ yarn install && npm run dev && sleep 1 && npm run dev
if [ ! -z "$version" ]; then
- log "Setting vue to$version_msg"
+ log "Upgrading vue to$version_msg"
# TODO: validate semver and valid version for the package so users cant pass in junk
yarn upgrade vue@$version
fi
[ "$install_bootstrap" == 1 ] && log "Bootstrap install directive found but ignored. Already installed."
else
- log "ERROR $err_code: There was a problem installing Vue$version_msg$auth_msg" -e
+ log "ERROR $err_code: There was a problem installing vue$auth_msg" -e
fi
fi
fi
# END: Optional vue install
-# TODO: test bootstrap install without any detection for an existing install.
-# If nothing is affected like app.js then install wont need to be skipped.
-# otherwise implement the same fix for existing installs that we have for react and vue.
-
+# TODO: log message when bootstrap is told to install but wont because of a prior installation of react or vue
# BEGIN: Optional bootstrap install
if [[ $install_bootstrap == 1 && $install_react == 0 && $install_vue == 0 ]]; then
version=$(eval $parse bootstrap version)
@@ -134,7 +135,7 @@ if [[ $install_bootstrap == 1 && $install_react == 0 && $install_vue == 0 ]]; th
[ -z "$version" ] && version_msg='' || version_msg=" version $version"
[ "$auth" != 1 ] && auth_msg='' || auth_msg=' with --auth'
log "Bootstrap install directive found in starter.ini"
- log "Installing Bootstrap"
+ log "Installing Bootstrap$auth_msg ..."
if [ "$auth" == 1 ]; then
php artisan ui bootstrap --auth
else
@@ -143,15 +144,15 @@ if [[ $install_bootstrap == 1 && $install_react == 0 && $install_vue == 0 ]]; th
err_code=$?
if [ $err_code == 0 ]; then
log "SUCCESS: Bootstrap$version_msg$auth_msg has been installed"
- log "Compiling fresh scaffolding and running Laravel Mix"
- yarn install && yarn run dev && sleep 1 && yarn run dev
+ log " --> Installing node modules and running Laravel Mix"
+ yarn install && npm run dev && sleep 1 && npm run dev
if [ ! -z "$version" ]; then
- log "Setting bootstrap to$version_msg"
+ log "Upgrading bootstrap to$version_msg"
# TODO: validate semver and valid version for the package so users cant pass in junk
yarn upgrade bootstrap@$version
fi
else
- >&2 log "ERROR $err_code: There was a problem installing Bootstrap$version_msg$auth_msg"
+ >&2 log "ERROR $err_code: There was a problem installing Bootstrap$auth_msg"
fi
else
version=$(eval $parse bootstrap version)
@@ -161,4 +162,5 @@ else
yarn upgrade bootstrap@$version
fi
fi
-# END: Optional bootstrap install
\ No newline at end of file
+# END: Optional bootstrap install
+# END: optional frontend scaffolding installations
diff --git a/bash/init-phpmyadmin.sh b/bash/init-phpmyadmin.sh
new file mode 100644
index 00000000..77f7ef78
--- /dev/null
+++ b/bash/init-phpmyadmin.sh
@@ -0,0 +1,135 @@
+#!/bin/bash
+
+# init-phpmyadmin.sh
+# Description:
+# Initial configuration for an existing phpmyadmin installation
+
+# Log to the console and a file
+log () {
+ if [ -z "$2" ]; then
+ bash bash/utils.sh log "$1" /var/log/workspace-init.log
+ else
+ bash bash/utils.sh log "$1" /var/log/workspace-init.log -e
+ fi
+}
+
+# Log only to a file
+log_silent () {
+ if [ -z "$2" ]; then
+ bash bash/utils.sh log_silent "$1" /var/log/workspace-init.log
+ else
+ bash bash/utils.sh log_silent "$1" /var/log/workspace-init.log -e
+ fi
+}
+
+# regexp pattern for checking an array of exit codes
+all_zeros_reg='^0$|^0*0$'
+
+# Load spinner
+. bash/third-party/spinner.sh
+
+parse="bash bash/utils.sh parse_ini_value starter.ini"
+
+# BEGIN: phpmyadmin setup if installed
+installed_phpmyadmin=$(bash bash/utils.sh parse_ini_value starter.ini phpmyadmin install)
+if [ "$installed_phpmyadmin" == 1 ]; then
+ if [ -e public/phpmyadmin/config.sample.inc.php ]; then
+ msg="Creating file public/phpmyadmin/config.inc.php"
+ log_silent "$msg" && start_spinner "$msg"
+ cp public/phpmyadmin/config.sample.inc.php public/phpmyadmin/config.inc.php
+ err_code=$?
+ if [ $err_code != 0 ]; then
+ stop_spinner $err_code
+ log "ERROR: Failed $msg" -e
+ else
+ stop_spinner $err_code
+ log_silent "SUCCESS: $msg"
+ fi
+ # Setup Blowfish secret
+ msg="Parsing blowfish secrect in public/phpmyadmin/config.inc.php"
+ log_silent "$msg ..." && start_spinner "$msg ..."
+ __bfs=$(bash bash/utils.sh generate_string 32)
+ sed -i'' "s#\\$cfg['blowfish_secret'] = '';#\\$cfg['blowfish_secret'] = '$__bfs';#g" public/phpmyadmin/config.inc.php
+ err_code=$?
+ if [ $err_code != 0 ]; then
+ stop_spinner $err_code
+ log "ERROR: Failed $msg" -e
+ else
+ stop_spinner $err_code
+ log_silent "SUCCESS: $msg"
+ fi
+ # Setup storage configuration
+ msg="Uncommenting storage configuration in public/phpmyadmin/config.inc.php"
+ log_silent "$msg" && start_spinner "$msg"
+ sed -i "/'controluser'/,/End of servers configuration/ s/^\/\/ *//" public/phpmyadmin/config.inc.php
+ err_code=$?
+ if [ $err_code != 0 ]; then
+ stop_spinner $err_code
+ log "ERROR: Failed $msg" -e
+ else
+ stop_spinner $err_code
+ log_silent "SUCCESS: $msg"
+ fi
+ fi
+ # Setup phpmyadmin db and storage tables
+ msg='Configuring phpmyadmin db and storage tables'
+ log_silent "$msg ..." && start_spinner "$msg"
+ mysql < public/phpmyadmin/sql/create_tables.sql
+ if [ $err_code != 0 ]; then
+ stop_spinner $err_code
+ log "ERROR: $msg" -e
+ else
+ stop_spinner $err_code
+ log_silent "SUCCESS: $msg"
+ fi
+
+ # Super user account for phpmyadmin
+ msg="Creating phpmyadmin superuser: pmasu"
+ log_silent "$msg" && start_spinner "$msg"
+ mysql -e "CREATE USER 'pmasu'@'%' IDENTIFIED BY '123456';"
+ mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'pmasu'@'%';"
+ err_code=$?
+ if [ $err_code != 0 ]; then
+ stop_spinner $err_code
+ log "ERROR: failed to create phpmyadmin superuser: pmasu" -e
+ else
+ log_silent "SUCCESS: $msg"
+ stop_spinner $err_code
+ fi
+ # Control user account for phpmyadmin (used for storage features)
+ msg="Creating phpmyadmin control user"
+ error_codes=()
+ log_silent "$msg..." && start_spinner "$msg.."
+ mysql -e "CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass';"
+ error_codes+=($?)
+ mysql -e "GRANT ALL PRIVILEGES ON \`phpmyadmin\`.* TO 'pma'@'localhost' WITH GRANT OPTION;"
+ error_codes+=($?)
+ mysql -e "FLUSH PRIVILEGES;"
+ error_codes+=($?)
+ error_codes=$(echo ${error_codes[*]} | tr -d '[:space:]')
+ if [[ $error_codes =~ $all_zeros_reg ]]; then
+ stop_spinner $err_code
+ log_silent "SUCCESS: $msg"
+ else
+ stop_spinner 0
+ log "ERROR: $msg" -e
+ fi
+ # Install node modules
+ if [ ! -d 'public/phpmyadmin/node_modules' ]; then
+ log "phpmyadmin node modules have not yet been installed, installing now..."
+ cd public/phpmyadmin && yarn install && cd ../../
+ if [ $? == 0 ]; then
+ __pmaurl=$(gp url 8001)/phpmyadmin
+ log_silent "phpmyadmin node modules installed."
+ log_silent "To login to phpmyadmin:"
+ log_silent " --> 1. Make sure you are serving it with apache"
+ log_silent " --> 2. In the browser go to $__pmaurl"
+ log_silent " --> 3. You should be able to login here using the defaults. user: pmasu, pw: 123456"
+ log_silent "Make sure you change the default passwords for the phpmyadmin accounts."
+ log_silent "For help with updating phpmyadmin passwords, run the alias help_update_pma_pws"
+ else
+ log "ERROR: installing phpmyadmin node modules. Try installing them manually." -e
+ fi
+ fi
+fi
+# END: phpmyadmin setup if installed
\ No newline at end of file
diff --git a/bash/scaffold-project.sh b/bash/scaffold-project.sh
index 429b25d3..a3cb9d36 100644
--- a/bash/scaffold-project.sh
+++ b/bash/scaffold-project.sh
@@ -9,30 +9,32 @@
# and all of this scripts dependencies have already been copied to /tmp
LOG='/var/log/workspace-image.log'
+SCAFF_NAME='laravel8-starter'
+SCAFF_DEST="/home/gitpod/$SCAFF_NAME"
echo "BEGIN: Scaffolding Laravel Project" | tee -a $LOG
-echo " Creating Laravel 8.x project in ~/temp-app..." | tee -a $LOG
-composer create-project --prefer-dist laravel/laravel test-app "8.*"
+echo " Creating Laravel 8.x project scaffolding in $SCAFF_DEST..." | tee -a $LOG
+composer create-project --prefer-dist laravel/laravel "$SCAFF_NAME" "8.*"
ERRCODE=$?
if [ $ERRCODE -ne 0 ]; then
- >&2 echo " ERROR $?: failed to create Laravel 8.23.x project temp-app" | tee -a $LOG
+ >&2 echo " ERROR $?: failed to create Laravel 8 project scaffolding in $SCAFF_DEST" | tee -a $LOG
else
- chown -R gitpod:gitpod /home/gitpod/test-app
- cd /home/gitpod/test-app
+ chown -R gitpod:gitpod "$SCAFF_DEST"
+ cd "$SCAFF_DEST"
VER=`php artisan --version`
- echo " SUCCESS: $VER project temp-app project created in ~/" | tee -a $LOG
+ echo " SUCCESS: $VER project scaffolding created in $SCAFF_DEST" | tee -a $LOG
# Handle optional install of phpmyadmin
install_phpmyadmin=$(. /tmp/utils.sh parse_ini_value /tmp/starter.ini phpmyadmin install);
if [ $install_phpmyadmin -eq 1 ]; then
echo " Phpmyadmin installation directive found in starter.ini" | tee -a $LOG
echo " Installing phpmyadmin..." | tee -a $LOG
- cd /home/gitpod/test-app/public && composer create-project phpmyadmin/phpmyadmin
+ cd "$SCAFF_DEST/public" && composer create-project phpmyadmin/phpmyadmin
ERRCODE_PHPMYADMIN=$?
if [ $ERRCODE_PHPMYADMIN -eq 0 ]; then
- chown -R gitpod:gitpod /home/gitpod/test-app/public/phpmyadmin
- echo " SUCCESS: phpmyadmin installed to ~/temp-app/public" | tee -a $LOG
+ chown -R gitpod:gitpod "$SCAFF_DEST/public/phpmyadmin"
+ echo " SUCCESS: phpmyadmin installed to $SCAFF_DEST/public" | tee -a $LOG
else
>&2 echo " ERROR $?: phpmyadmin failed to install" | tee -a $LOG
fi
diff --git a/bash/snippets/editorconfig/laravel-js-2space b/bash/snippets/editorconfig/laravel-js-2space
index e6d1b86e..cf914828 100644
--- a/bash/snippets/editorconfig/laravel-js-2space
+++ b/bash/snippets/editorconfig/laravel-js-2space
@@ -15,4 +15,7 @@ indent_size = 4
trim_trailing_whitespace = false
[*.{yml,yaml}]
-indent_size = 2
\ No newline at end of file
+indent_size = 2
+
+[*.txt]
+insert_final_newline = false
\ No newline at end of file
diff --git a/bash/snippets/emoji-log b/bash/snippets/emoji-log
index 1676d211..eda33dbc 100644
--- a/bash/snippets/emoji-log
+++ b/bash/snippets/emoji-log
@@ -6,6 +6,8 @@
# See https://github.com/ahmadawais/Emoji-Log
# Git Commit, Add all and Push — in one step.
cap = "!f() { git add .; git commit -m \"$@\"; git push; }; f"
+# Git Commit and Push. Assumes files have already been added
+noadd = "!f() { git commit -m \"$@\"; git push; }; f"
# NEW: any initial commit
new = "!f() { git cap \"📦 NEW: $@\"; }; f"
# IMPROVE: Any feature or enhancement
@@ -20,4 +22,48 @@ doc = "!f() { git cap \"📖 DOC: $@\"; }; f"
tst = "!f() { git cap \"🤖 TEST: $@\"; }; f"
# BREAKING CHANGE: anything that breaks the previous version/release
brk = "!f() { git cap \"‼️ BREAKING: $@\"; }; f"
-# END: Emoji-Log standards
\ No newline at end of file
+# END: Emoji-Log standards
+# BEGIN: Additional Gitmojis, see https://gitmoji.dev/
+# REF: anything related to factoring code
+ref = "!f() { git cap \"♻️ REFACTOR: $@\"; }; f"
+# TYP: typos in code, docs, comments, etc...
+typ = "!f() { git cap \"✏️ FIX TYPO: $@\"; }; f"
+# REV: revert changes to a previous commit
+rev = "!f() { git cap \"⏪ REVERT: $@\"; }; f"
+# MER: Merge Branches, code, etc...
+mer = "!f() { git cap \"🔀 MERGE: $@\"; }; f"
+# MVR: Move or rename resources (e.g.: files, paths, routes)
+mvr = "!f() { git cap \"🚚 MOVE/RENAME: $@\"; }; f"
+# COM: Add or update comments in source code
+com = "!f() { git cap \"💡 UPDATE COMMENTS: $@\"; }; f"
+# DAT: Perform database related changes (e.g. Migrations, seeds, APIs)
+dat = "!f() { git cap \"🗃️ DATABASE: $@\"; }; f"
+# IGN: Add or update a .gitignore file.
+ign = "!f() { git cap \"🙈 GITIGNORE: $@\"; }; f"
+# WRK: Workaround or temporary fix
+wrk = "!f() { git cap \"🩹 TEMP FIX: $@\"; }; f"
+# REM: Remove ddead/unused code
+rem = "!f() { git cap \"⚰️ REMOVE: $@\"; }; f"
+# AD: Add libs, code, etc
+ad = "!f() { git cap \"➕ ADD: $@\"; }; f"
+# END: Additional Gitmojis
+# BEGIN: commit and push only, no add (use for groups of files that need different commit messages)
+new-c = "!f() { git noadd \"📦 NEW: $@\"; }; f"
+imp-c = "!f() { git noadd \"👌 IMPROVE: $@\"; }; f"
+fix-c = "!f() { git noadd \"🐛 FIX: $@\"; }; f"
+rlz-c = "!f() { git noadd \"🚀 RELEASE: $@\"; }; f"
+doc-c = "!f() { git noadd \"📖 DOC: $@\"; }; f"
+tst-c = "!f() { git noadd \"🤖 TEST: $@\"; }; f"
+brk-c = "!f() { git noadd \"‼️ BREAKING: $@\"; }; f"
+ref-c = "!f() { git noadd \"♻️ REFACTOR: $@\"; }; f"
+typ-c = "!f() { git noadd \"✏️ FIX TYPO: $@\"; }; f"
+rev-c = "!f() { git noadd \"⏪ REVERT: $@\"; }; f"
+mer-c = "!f() { git noadd \"🔀 MERGE: $@\"; }; f"
+mvr-c = "!f() { git noadd \"🚚 MOVE/RENAME: $@\"; }; f"
+com-c = "!f() { git noadd \"💡 UPDATE COMMENTS: $@\"; }; f"
+dat-c = "!f() { git noadd \"🗃️ DATABASE: $@\"; }; f"
+ign-c = "!f() { git noadd \"🙈 GITIGNORE: $@\"; }; f"
+wrk-c = "!f() { git noadd \"🩹 TEMP FIX: $@\"; }; f"
+rem-c = "!f() { git noadd \"⚰️ REMOVE: $@\"; }; f"
+add-c = "!f() { git noadd \"➕ ADD: $@\"; }; f"
+# END: commit and push only, no add
\ No newline at end of file
diff --git a/bash/snippets/grc/rsync-stats b/bash/snippets/grc/rsync-stats
new file mode 100644
index 00000000..7185cf30
--- /dev/null
+++ b/bash/snippets/grc/rsync-stats
@@ -0,0 +1,15 @@
+# all words
+regexp=\b[^\d\W]+\b
+colours="\033[38;5;35m"
+-
+# all numbers
+regexp=\d+
+colours=bold green
+-
+# bytes,seconds, bytes/sec
+regexp=bytes|sec|onds
+colours=magenta
+-
+# M or K if preceded by a number (lookbehind)
+regexp=(?<=[0-9])(M|K)
+colours=bold cyan
\ No newline at end of file
diff --git a/bash/snippets/messages/help-update-pma-pws.txt b/bash/snippets/messages/help-update-pma-pws.txt
new file mode 100644
index 00000000..1bdba8ce
--- /dev/null
+++ b/bash/snippets/messages/help-update-pma-pws.txt
@@ -0,0 +1,6 @@
+The following steps are required to run the `update_phpmyadmin_pws` alias without failures:
+ 1. Create a file in the root of the project named `.starter.env`
+ 2. Copy and paste all the keys containing `PHPMYADMIN` from `.starter.env.example` to `.starter.env`
+ 3. In .starter.ini, set password values for the `PHPMYADMIN` keys and save the file.
+ 4. In a terminal run the alias: `update_phpmyadmin_pws`
+This information can also be found at https://github.com/apolopena/gitpod-laravel8-starter/blob/main/README.md#securing-phpmyadmin
\ No newline at end of file
diff --git a/bash/snippets/messages/phpmyadmin-security.txt b/bash/snippets/messages/phpmyadmin-security.txt
new file mode 100644
index 00000000..6efa0d2d
--- /dev/null
+++ b/bash/snippets/messages/phpmyadmin-security.txt
@@ -0,0 +1,3 @@
+You have installed phpMyAdmin with default user account passwords.
+This is a security concern and be easily addressed using the alias: update_pma_pws
+For more information on using update_pma_pws, run the alias: help_update_pma_pws
\ No newline at end of file
diff --git a/bash/utils.sh b/bash/utils.sh
index cab5a3d9..7af718d6 100644
--- a/bash/utils.sh
+++ b/bash/utils.sh
@@ -10,7 +10,7 @@
version () {
- echo "utils.sh version 0.0.5"
+ echo "utils.sh version 0.0.7"
}
# Use absolute paths or paths relative to this script
@@ -125,9 +125,9 @@ parse_ini_value() {
#
log () {
if [[ "$3" == '-e' || "$3" == '--error' ]]; then
- >&2 echo -e "$1" && printf "$1\n" >> "$2"
+ >&2 echo -e "$1" && printf -- "$1\n" >> "$2"
else
- echo -e "$1" && printf "$1\n" >> "$2"
+ echo -e "$1" && printf -- "$1\n" >> "$2"
fi
}
@@ -148,9 +148,9 @@ log () {
#
log_silent () {
if [[ "$3" == '-e' || "$3" == '--error' ]]; then
- 1>&2 printf "$1\n" >> "$2"
+ 1>&2 printf -- "$1\n" >> "$2"
else
- printf "$1\n" >> "$2"
+ printf -- "$1\n" >> "$2"
fi
}
@@ -184,6 +184,73 @@ node_package_exists () {
ls "$path" 2>/dev/null | grep -w $1 >/dev/null 2>&1 && echo "1" || echo "0"
}
+# generate_string
+# Description:
+# Generates a string of random alphanumeric and special charaters of any length ($1)
+# The length of the string defaults to 32 if no argument is passed in
+# or if the argument passed in is empty or not a valid positive integer
+#
+# Usage:
+# Example 1: generate a random string with a length of 8
+# generate_string 8
+#
+# Example 2: generate a random string with a length of 32
+# generate_string
+#
+generate_string () {
+ [ "$1" -ge 0 ] 2>/dev/null && local count=$1 || local count=32
+ echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9$+,:;=?|<>.^*()%-' | fold -w $count | head -n 1)
+}
+
+# get_env_value
+# Description:
+# Get the value of a key ($1) value pair as set in a env style file ($2)
+# If no file ($2) argument is given then the file .starter.env will be used
+#
+# Exit codes:
+# 3 --> File ($2 or the default .starter.env) does not exist
+# 4 --> Variable ($1) does not exist in file ($2 or the default .starter.env)
+# 5 --> Value for the variable ($2) was not set or contained only whitespace
+#
+# Usage:
+# Example 1 (with optional error handling):
+# # Get the value of PHP_PW from .starter.env, assuming the file contains PHP_PW=secret007
+# # If there are no errors then the output would be secret007
+# err="get_env_value Error:"
+# value="$(get_env_value PHP_PW)"
+# case "$?" in
+# '0')
+# echo $value
+# ;;
+# '3')
+# echo "$err No file .starter.env"
+# ;;
+# '4')
+# echo "$err No variable: PHP_PW"
+# ;;
+# '5')
+# echo "$err No value for variable: PHP_PW"
+# ;;
+# *)
+# echo "$err unidentified exit code: $?"
+# ;;
+# esac
+#
+# Example 2 (no error handling):
+# # Get the value of FOO from .bar (assume the file .bar contains FOO=foobarbaz)
+# # If there are no errors the output would be foobarbaz, otherwise there would be no output.
+# get_env_value FOO .bar
+#
+get_env_value() {
+ [ -z "$2" ] && local file='.starter.env' || local file="$2"
+ [ ! -f "$file" ] && exit 3
+ grep -q "$1=" $file
+ [ $? != 0 ] && exit 4
+ local val=$(grep "$1=" .starter.env | cut -d '=' -f2)
+ [ -z $val ] && exit 5
+ echo $val
+}
+
# Call functions from this script gracefully
if declare -f "$1" > /dev/null
diff --git a/starter.ini b/starter.ini
index 8c85818f..fb6812c1 100644
--- a/starter.ini
+++ b/starter.ini
@@ -31,7 +31,7 @@ install=0
# An install of react also installs and upgrades react-dom to the same version set below
# if install = 1 then vue will not be installed if its install value is also set to 1
install=0
-auth=1
+auth=0
version=^17.0.1
[vue]
@@ -44,11 +44,11 @@ version=
# Installs of either react or vue have bootstrap already so this section will be superceded in those cases
install=0
# auth only appies here when react or vue are not installed.
-auth=1
+auth=0
version=
[github-changelog-generator]
-# Installs https://github.com/github-changelog-generator/github-changelog-generator
-install=1
+# Installs a ruby gem from https://github.com/github-changelog-generator/github-changelog-generator
+install=0
since_tag=
future_release=
\ No newline at end of file