generaxion / axio-starter

Superior WordPress starter theme with modern build tools by Generaxion (previously Aucor Starter). 250+ hours of development over 6 years to make the greatest starting point for WordPress site.
https://axio.generax.io
GNU General Public License v2.0
165 stars 25 forks source link

setup.sh is not compatible with GNU version of sed #2

Closed taehtinen closed 6 years ago

taehtinen commented 6 years ago

Setup.sh has been created using the BSD version of sed, used for example in OSX, and is not compatible with the GNU version found on many Linux systems. The following error occurs:

sed: can't read s/aucor_starter/sivu/g: No such file or directory

Maybe use perl instead for doing the replacement? It'll work the same way on both. For example:

find $basedir -name 'style.css' -type f -exec perl -p -i -e "s/$default_name/$name/g" {} \;

TeemuSuoranta commented 6 years ago

Thank you for reporting! We have only used OSX while developing so we haven't noticed this limitation yet. I'll look into this and try to make this compatible for Linux users as well.

TeemuSuoranta commented 6 years ago

Can you try out following setup.sh? I got it working with perl on Mac but it would be nice to have it tested on Linux before commiting. So replace setup.sh with following:

#!/bin/bash
# Theme setup.

# Defaults
default_name="Aucor Starter"
default_id="aucor_starter"
default_url="https://aucor_starter.local"
default_locale="fi"

# Directories
basedir="$( cd "$( dirname "$0" )" && pwd )/."
assetsdir="$basedir/assets"
basedir_all_files="$basedir/."
setup_script="$basedir/setup.sh"

# Text styles
bold=$(tput bold)
white=$(tput setaf 7)
pink=$(tput setaf 198)
green=$(tput setaf 2)
txtreset=$(tput sgr0)

echo "${bold}${pink}
    aucorauco     aucoraucor
  raucoraucorau   coraucoraucor
 corauc     or  aucora     ucora
ucora          ucora        ucora
ucor         aucora         ucora
 aucor      aucorauc       orauc
  oraucoraucorau coraucorauauco
    raucoraucor     aucoraucor    ${txtreset}"
echo "${bold}
        aucor-starter
      ${txtreset}"

echo "1) Set name for your theme. (Default: $default_name)"
read name
# use default if empty
if test -n "$name"; then
  echo ""
else
  id=$default_name
fi

echo "2) Set unique id for your theme. Use only a-z and _. (Default: $default_id)"
read id

# use default if empty
if test -n "$id"; then
  echo ""
else
  id=$default_id
fi

echo "3) Set local development url. (Default: $default_url)"
read url

# use default if empty
if test -n "$url"; then
  echo ""
else
  url=$default_url
fi

while true; do
read -p "4) Is following information correct?

name: ${bold}${pink}$name${txtreset} (Default: $default_name)
id: ${bold}${pink}$id${txtreset} (Default: $default_id)
url: ${bold}${pink}$url${txtreset} (Default: $default_url)

Proceed to install? [y/N]
" yn
  case $yn in
    [Yy]* ) break;;
    [Nn]* ) exit;;
    * ) echo "Please answer y or n.";;
  esac
done

echo "
Run setup:
=========="

# style.css
find $basedir -name 'style.css' -type f -exec perl -p -i -e "s|$default_name|$name|g" {} \;

# PHP files
find $basedir_all_files -name '*.php' -type f -exec perl -p -i -e "s|$default_name|$name|g" {} \;

echo "--> Search & replace name ... ${green}done${txtreset}"

# PHP files
find $basedir_all_files -name '*.php' -type f -exec perl -p -i -e "s|$default_id|$id|g" {} \;

# style.css
find $basedir -name 'style.css' -type f -exec perl -p -i -e "s|$default_id|$id|g" {} \;

# bower.json
find $basedir -name 'bower.json' -type f -exec perl -p -i -e "s|$default_id|$id|g" {} \;

# package.json
find $basedir -name 'package.json' -type f -exec perl -p -i -e "s|$default_id|$id|g" {} \;

echo "--> Search & replace id ..... ${green}done${txtreset}"

# manifest.json
find $assetsdir -name 'manifest.json' -type f -exec perl -p -i -e "s|$default_url|$url|g" {} \;

echo "--> Change url .............. ${green}done${txtreset}"

echo "--> ${green}Setup complete!${txtreset}"

echo "--> setup.sh removed"
rm $setup_script
taehtinen commented 6 years ago

Yes, this works on Ubuntu Linux, everything got replaced as they should have.

kauaicreative commented 3 years ago

This works update works. Why not merge into master?

TeemuSuoranta commented 3 years ago

The master uses the perl version but it was not very clear from this issue. So issue was fixed back in 2017.

kauaicreative commented 3 years ago

@TeemuSuoranta your code above works. But not the current setup.sh from master I am using WSL - windows subsystem for Linux

Here is what I am seeing:

  1. clone current aucor-starter
  2. sh setup.sh
  3. Enter new theme name

This is the output and errors.

image

kauaicreative commented 3 years ago

Might be worth converting this to gulp for complete compatibility

kauaicreative commented 3 years ago

My WSL issue above is fixed if I git clone from SWL - clone from Ubuntu not Windows. Or change the line endings of the setup.sh file to LF (Linux)