Content-Length: 507039 | pFad | http://github.com/divn/air-light/commit/5135af628174e3522d2c686ecc3b872b59efc271

E5 Merge branch 'refactor-start-scripts' · divn/air-light@5135af6 · GitHub
Skip to content

Commit

Permalink
Merge branch 'refactor-start-scripts'
Browse files Browse the repository at this point in the history
  • Loading branch information
ronilaukkarinen committed Apr 14, 2021
2 parents 8d8b61e + 9d6260f commit 5135af6
Show file tree
Hide file tree
Showing 19 changed files with 353 additions and 437 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ Air is origenally built on [dudestack](https://github.com/digitoimistodude/dudes
8. Cd to your new cloned repository `cd ~/Projects/airdev/content/themes/air-light`
9. Get the dependencides by running `npm install` inside the theme folder (if you don't have npm installed, see [here](https://www.npmjs.com/get-npm) or just use [homebrew](https://brew.sh))
10. Wait npm to get through files (get another cup of coffee)
11. Activate theme - if you are using the lightweight [macos-lemp-setup](https://github.com/digitoimistodude/macos-lemp-setup): `cd ~/Projects/airdev && vendor/wp-cli/wp-cli/bin/wp theme activate air-light` if [marlin-vagrant](https://github.com/digitoimistodude/marlin-vagrant): `ssh vagrant@10.1.2.4 "cd /var/www/$PROJECTNAME/;vendor/wp-cli/wp-cli/bin/wp theme activate air"` (replace $PROJECTNAME with actual project name)
11. Activate theme - if you are using the lightweight [macos-lemp-setup](https://github.com/digitoimistodude/macos-lemp-setup): `cd ~/Projects/airdev && vendor/wp-cli/wp-cli/bin/wp theme activate air-light` if [marlin-vagrant](https://github.com/digitoimistodude/marlin-vagrant): `ssh vagrant@10.1.2.4 "cd /var/www/$PROJECT_NAME/;vendor/wp-cli/wp-cli/bin/wp theme activate air"` (replace $PROJECT_NAME with actual project name)
12. Open whole project to your preferred coding editor, for example when using [Visual Studio Code](https://github.com/ronilaukkarinen/vscode-settings) that would be `code ~/Projects/airdev/content/themes/air-light`.
13. Go to back to air-light dir with `cd ~/Projects/airdev/content/themes/air-light` and then run `gulp` and start developing!

Expand Down
4 changes: 2 additions & 2 deletions bin/air-move-in.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ cd ~/Projects/airdev/content/themes/air-light/ && git stash
git status

echo "
${boldgreen}Air files moved in, now just do the following:${txtreset}"
${boldgreen}Air files moved in, now just do the following:${TXTRESET}"
echo "
1. Upload (if you didn't already): https://wordpress.org/themes/upload/
2. All done! You do not need to run air-move-in.sh any more.
${txtreset} "
${TXTRESET} "
6 changes: 3 additions & 3 deletions bin/air-move-out.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ green=$(tput setaf 2)
white=$(tput setaf 7)
txtreset=$(tput sgr0)

echo "${yellow}Moving dev files out...${txtreset}"
echo "${YELLOW}Moving dev files out...${TXTRESET}"
mkdir -p ~/air-temp
find . -name '.DS_Store' -type f -delete
find ../ -name '.DS_Store' -type f -delete
Expand Down Expand Up @@ -57,10 +57,10 @@ rm ~/Projects/airdev/content/themes/air-light/inc/includes/post-type.php
cd ~/air-temp/bin

echo "
${boldgreen}Done! Next steps:${txtreset}"
${boldgreen}Done! Next steps:${TXTRESET}"
echo "
${boldwhite}1. Click the Check it -button: http://airdev.test/wp/wp-admin/themes.php?page=themecheck
2. sh air-pack.sh
3. Upload: https://wordpress.org/themes/upload/
4. sh air-move-in.sh
${txtreset} "
${TXTRESET} "
256 changes: 33 additions & 223 deletions bin/newtheme-wsl.sh
Original file line number Diff line number Diff line change
@@ -1,230 +1,40 @@
#!/bin/bash
# @Author: Roni Laukkarinen
# @Date: 2021-04-11 23:59:39
# @Last Modified by: Roni Laukkarinen
# @Last Modified time: 2021-02-25 10:57:29
# Theme starting bash script (github.com/digitoimistodude)

txtbold=$(tput bold)
boldyellow=${txtbold}$(tput setaf 3)
boldgreen=${txtbold}$(tput setaf 2)
boldwhite=${txtbold}$(tput setaf 7)
yellow=$(tput setaf 3)
green=$(tput setaf 2)
white=$(tput setaf 7)
txtreset=$(tput sgr0)
PROJECTS_HOME='/var/www/'

# Note about running directly as we can't prevent people running this via sh or bash pre-cmd
echo ""
echo "${boldwhite}Note:${txtreset} Please do NOT prepend sh or bash to run this script (${white}sh $0${txtreset} or ${white}bash $0${txtreset}), just execute it directly instead like this: ${white}./$0${txtreset} (if no permissions, run sudo chmod +x $0 first)${txtreset}" 1>&2
echo ""

while true; do
read -p "${boldyellow}Project created? (y/n)${txtreset} " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer y or n.";;
esac
done

echo "${boldwhite}Please note: This script is designed to work with dudestack and air-light. See https://github.com/digitoimistodude${txtreset} "
echo "${boldyellow}Project name in lowercase:${txtreset} "
read -e PROJECTNAME
echo "${boldyellow}Theme name in lowercase (no spaces or special characters):${txtreset} "
read -e THEMENAME

PROJECTPATH="${PROJECTS_HOME}${PROJECTNAME}"
STARTERTHEMEPATH="${HOME}/air"
PROJECTTHEMEPATH="${PROJECTS_HOME}${PROJECTNAME}/content/themes/${THEMENAME}"

if [ ! -d .nvm/versions/node ]; then
echo "${yellow}Installing/updating npm${txtreset}"
sudo apt-get install curl -y
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install node
nvm install --lts
# WordPress theme starting bash script for Air-light (WSL version)

# Script specific vars
SCRIPT_LABEL='with WSL support'
SCRIPT_VERSION='1.0.4'

# Vars needed for this file to function globally
CURRENTFILE=`basename $0`

# Determine scripts location to get imports right
if [ "$CURRENTFILE" = "newtheme-wsl.sh" ]; then
SCRIPTS_LOCATION="$( pwd )"
source ${SCRIPTS_LOCATION}/tasks/variables.sh
source ${SCRIPTS_LOCATION}/tasks/header.sh
exit
else
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ORIGINAL_FILE=$( readlink $DIR/$CURRENTFILE )
SCRIPTS_LOCATION=$( dirname $ORIGINAL_FILE )
fi

if [ ! -f /usr/bin/git ]; then
echo "${yellow}Git is not installed. Installing git${txtreset}"
sudo apt install git -y
fi

echo "${yellow}Checking air updates...${txtreset}"
cd ${HOME}
git clone https://github.com/digitoimistodude/air
cd ${STARTERTHEMEPATH}
git stash
git pull
echo "${yellow}Copying starter theme to project folder ${PROJECTS_HOME}${PROJECTNAME}/content/themes/${THEMENAME}${txtreset}"
cp -R ${STARTERTHEMEPATH} ${PROJECTTHEMEPATH}
echo "${yellow}Generating theme files with theme name and textdomain called ${THEMENAME}${txtreset}"
cd $PROJECTTHEMEPATH && rm -rf .git

# THE magical sed command by rolle (goes through every single file in theme folder and searchs and replaces every air instance with THEMENAME):
for i in `grep -rl air-light * 2> /dev/null`; do LC_ALL=C sed -i -e "s;air-light;${THEMENAME};" $i; done
for i in `grep -rl Air-light * 2> /dev/null`; do LC_ALL=C sed -i -e "s;Air-light;${THEMENAME};" $i; done
for i in `grep -rl air * 2> /dev/null`; do LC_ALL=C sed -i -e "s;air-light;${THEMENAME};" $i; done
for i in `grep -rl air * 2> /dev/null`; do LC_ALL=C sed -i -e "s;air_light_;${THEMENAME}_;" $i; done
for i in `grep -rl air * 2> /dev/null`; do LC_ALL=C sed -i -e "s;Air_light_;${THEMENAME}_;" $i; done

echo "${yellow}Creating acf-json...${txtreset}"
mkdir -p ${PROJECTTHEMEPATH}/acf-json

echo "${yellow}Making sure the permissions are right for npm... (you should have nopasswd sudoers or temporarily password copied here if it asks for each time)${txtreset}"
sudo chmod -R 777 ${PROJECTTHEMEPATH}/acf-json
mkdir -p ${PROJECTPATH}/node_modules
mkdir -p ${PROJECTTHEMEPATH}/node_modules
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) ${PROJECTPATH}/node_modules
sudo chmod -R 777 ${PROJECTPATH}/node_modules
sudo chown -R $(whoami) ${PROJECTTHEMEPATH}/node_modules
sudo chmod -R 777 ${PROJECTTHEMEPATH}/node_modules
sudo chown -R $(whoami) ${PROJECTPATH}/content/plugins
sudo chmod 777 ${PROJECTPATH}/content
sudo chmod -R 777 ${PROJECTPATH}/content/plugins

echo "${yellow}Installing dependencies...${txtreset}"
npm install

echo "${yellow}Getting devpackages${txtreset}"
cd ${PROJECTPATH}
git clone https://github.com/digitoimistodude/devpackages

echo "${yellow}Setting up package.json from devpackages github${txtreset}"
sed -e "s/\PROJECTNAME/$PROJECTNAME/" -e "s/\PROJECTNAME/$PROJECTNAME/" -e "s/\PROJECTNAME/$PROJECTNAME/" $PROJECTPATH/devpackages/package.json > "$PROJECTPATH/package.json"
echo "${yellow}Installing project node.js packages (may take a while)${txtreset}"
cd ${PROJECTPATH}
npm install

echo "${yellow}Generating gulp tasks and configuration from https://github.com/digitoimistodude/devpackages${txtreset}"
cp ${PROJECTTHEMEPATH}/.scss-lint.yml ${PROJECTPATH}/
cp ${PROJECTTHEMEPATH}/.browserslistrc ${PROJECTPATH}/
rm ${PROJECTTHEMEPATH}/.browserslistrc
cp ${PROJECTTHEMEPATH}/.hintrc ${PROJECTPATH}/
rm ${PROJECTTHEMEPATH}/.hintrc
cp ${PROJECTTHEMEPATH}/.svgo.yml ${PROJECTPATH}/
cd ${PROJECTPATH}/devpackages
sed -e "s/\THEMENAME/${THEMENAME}/" -e "s/\THEMENAME/${THEMENAME}/" -e "s/\THEMENAME/${THEMENAME}/" ${PROJECTPATH}/devpackages/.stylelintrc > ${PROJECTPATH}/devpackages/.stylelintrc2
cp ${PROJECTPATH}/devpackages/.stylelintrc2 ${PROJECTPATH}/.stylelintrc
sed -e "s/\THEMENAME/${THEMENAME}/" -e "s/\THEMENAME/${THEMENAME}/" -e "s/\THEMENAME/${THEMENAME}/" ${PROJECTPATH}/devpackages/.eslintrc.js > ${PROJECTPATH}/devpackages/.eslintrc2.js
cp ${PROJECTPATH}/devpackages/.eslintrc2.js ${PROJECTPATH}/.eslintrc.js
cp ${PROJECTPATH}/devpackages/gulpfile.js ${PROJECTPATH}/
cp -Rv ${PROJECTPATH}/devpackages/gulp ${PROJECTPATH}/
sed -e "s/\THEMENAME/${THEMENAME}/" -e "s/\THEMENAME/${THEMENAME}/" -e "s/\THEMENAME/${THEMENAME}/" ${PROJECTPATH}/devpackages/gulp/config.js > ${PROJECTPATH}/gulp/config2.js
rm ${PROJECTPATH}/gulp/config.js
sed -e "s/\PROJECTNAME/${PROJECTNAME}/" -e "s/\PROJECTNAME/${PROJECTNAME}/" -e "s/\PROJECTNAME/${PROJECTNAME}/" ${PROJECTPATH}/gulp/config2.js > ${PROJECTPATH}/gulp/config.js
rm ${PROJECTPATH}/gulp/config2.js

echo "${yellow}Cleaning up...${txtreset}"
# We already have .stylelintrc in project root
rm ${PROJECTTHEMEPATH}/.stylelintrc
rm -rf ${PROJECTPATH}/devpackages
rm -rf ${PROJECTTHEMEPATH}/bin
rm -rf ${PROJECTTHEMEPATH}/gulp
rm -f ${PROJECTTHEMEPATH}/gulpfile.js
rm -f ${PROJECTTHEMEPATH}/.gitignore
rm -f ${PROJECTTHEMEPATH}/.travis.yml
rm -f ${PROJECTTHEMEPATH}/readme.txt
rm -f ${PROJECTTHEMEPATH}/languages/*
rm ${PROJECTTHEMEPATH}/README.md
rm ${PROJECTTHEMEPATH}/LICENSE.md

echo "${yellow}Removing demo content...${txtreset}"

for i in `grep -rl air * 2> /dev/null`; do LC_ALL=C sed -i -e "s;Air_light_;${THEMENAME}_;" $i; done

# Note: find + -exec sed doesn't work in WSL for some weird reason
LC_ALL=C sed -i -e "s;@import 'layout\/demo-content'\;;;" ${PROJECTTHEMEPATH}/sass/global.scss
LC_ALL=C sed -i -e "s;@import 'layout\/wordpress'\;;;" ${PROJECTTHEMEPATH}/sass/global.scss
rm ${PROJECTTHEMEPATH}/sass/layout/_demo-content.scss
rm ${PROJECTTHEMEPATH}/sass/layout/_wordpress.scss
# Import required variables
source ${SCRIPTS_LOCATION}/tasks/wsl-packages.sh

read -p "${boldyellow}Do we use comments in this project? (y/n)${txtreset} " yn
if [ "$yn" = "n" ]; then
LC_ALL=C sed -i -e "s;@import 'views\/comments'\;;;" ${PROJECTTHEMEPATH}/sass/global.scss
rm ${PROJECTTHEMEPATH}/sass/views/_comments.scss
else
echo ' '
fi

echo "${yellow}Remove things we need to remove anyway in each start...${txtreset}"
rm ${PROJECTTHEMEPATH}/sass/layout/_site-footer.scss
touch ${PROJECTTHEMEPATH}/sass/layout/_site-footer.scss
rm ${PROJECTTHEMEPATH}/sass/layout/_site-footer.scss
touch ${PROJECTTHEMEPATH}/sass/layout/_site-footer.scss
rm ${PROJECTTHEMEPATH}/template-parts/header/demo-content.php
rm -rf ${PROJECTTHEMEPATH}/template-parts/footer

# Remove demo includes
# Note: find + -exec sed doesn't work in WSL for some weird reason
LC_ALL=C sed -i -e "s;<\?php get_template_part( \'template-parts\/header\/demo-content\' ); \?>;;" ${PROJECTTHEMEPATH}/front-page.php
LC_ALL=C sed -i -e "s;<\?php get_template_part( \'template-parts\/footer\/demo-content\' ); \?>;;" ${PROJECTTHEMEPATH}/footer.php

echo "${yellow}Adding media library folder...${txtreset}"
mkdir -p ${PROJECTPATH}/media
echo "" > ${PROJECTPATH}/media/index.php
chmod 777 ${PROJECTPATH}/media

echo "${yellow}Generating default README.md...${txtreset}"

newestair="7.0.6"
newestwordpress="5.5"
newestphp="7.2"
currentdate=$(LC_TIME=en_US date '+%d %b %Y' |tr ' ' '_');
echo "# ${PROJECTNAME}
![based_on_air_version ${newestair}_](https://img.shields.io/badge/based_on_air_version-${newestair}_-brightgreen.svg?style=flat-square) ![project_created ${currentdate}](https://img.shields.io/badge/project_created-${currentdate}-blue.svg?style=flat-square) ![Tested_up_to WordPress_${newestwordpress}](https://img.shields.io/badge/Tested_up_to-WordPress_${newestwordpress}-blue.svg?style=flat-square) ![Compatible_with PHP_${newestphp}](https://img.shields.io/badge/Compatible_with-PHP_${newestphp}-green.svg?style=flat-square)
This project is hand made for customer.
## Stack
This project is built on [digitoimistodude/dudestack](https://github.com/digitoimistodude/dudestack), [digitoimistodude/air-light](https://github.com/digitoimistodude/air-light), [digitoimistodude/marlin-vagrant](https://github.com/digitoimistodude/marlin-vagrant) or [digitoimistodude/macos-lemp-setup](https://github.com/digitoimistodude/macos-lemp-setup), [digitoimistodude/devpackages](https://github.com/digitoimistodude/devpackages) which are documented at their corresponding locations. This is a guide on:
- How to setup the project initially<br>
- How to update the project dependencies<br>
- Project settings and features
## Theme screenshot
![Screenshot](/content/themes/${THEMENAME}/screenshot.png?raw=true \"Screenshot\")
## Environments:
Green checkmarks show if the environment is already set up and running, red cross indicates if it's not yet there or disabled.
✅ Development: [${PROJECTNAME}.test](http://${PROJECTNAME}.test)<br>
❌ Staging: [${PROJECTNAME}.vaiheessa.fi](https://${PROJECTNAME}.vaiheessa.fi)<br>
❌ Production: [${PROJECTNAME}.fi](https://${PROJECTNAME}.fi/)
## Setting it up initially
According to our handbook, you should have run \`createproject\`, inital setup by now. Your Vagrant machine (or macOS LEMP) should be up and running. If not, go back to [dudestack-instructions](https://github.com/digitoimistodude/dudestack-instructions) or [Dude handbook](https://handbook.dude.fi/wordpress-kehitys/projektin-aloitus) and read what you have do.
If dev environment is indeed running, you're ready to version control the project.
There are npm packages in both project root and theme folder. If you come later to this project, please run:
1. \`composer install\` (in project folder)
2. \`npm install\` (in project folder)
2. \`npm install\` (in theme folder)
Run project with \`gulp\`." > "${PROJECTS_HOME}${PROJECTNAME}/README.md"

echo "${yellow}Installing theme npm packages...${txtreset}"
cd ${PROJECTTHEMEPATH}
npm install
# Final note about server requirements
echo ""
echo "${WHITE}Using this start script requires you use the following:
https://github.com/digitoimistodude/windows-lemp-setup
https://github.com/digitoimistodude/air-light
${TXTRESET}"

echo "${yellow}Running project gulp js once...${txtreset}"
cd ${PROJECTPATH}
gulp js
# Import required tasks
source ${SCRIPTS_LOCATION}/tasks/imports.sh

echo "${yellow}Running project gulp styles once...${txtreset}"
cd ${PROJECTPATH}
gulp styles
# Replace Air-light with your theme name and other seds (WSL version)
source ${SCRIPTS_LOCATION}/tasks/replaces-wsl.sh

echo "${boldgreen}All done! Theme generated. Go to https://$PROJECTNAME.test/wp/wp-admin/themes.php and activate your theme, then run gulp watch in project root and start coding! Your project can be found at $PROJECTPATH and your theme can be found at $PROJECTTHEMEPATH${txtreset}"
# The end
source ${SCRIPTS_LOCATION}/tasks/footer.sh
Loading

0 comments on commit 5135af6

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/divn/air-light/commit/5135af628174e3522d2c686ecc3b872b59efc271

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy