Commit 8344ef33 authored by Stefan Galinski's avatar Stefan Galinski 🎮

[TASK] Cleanup files based on the editorconfig, eslint fixes, shellint

parent cac2ee4a
......@@ -2,7 +2,7 @@
## SPL (Sgalinski Plugin License)
Copyright (c) 2018 sgalinski Internet Services
Copyright (c) 2020 sgalinski Internet Services
Software released under this license is allowed to be used for commercial purposes and ads can be removed by paying a small fee. Permission is only granted to use the software. Any other actions, including copying, modifying, merging, publishing, distribution, sublicensing and / or selling copies are strictly prohibited!
......
{
"name": "sgalinski/sgc-core",
"description": "sgalinski command line interface",
"homepage": "https://www.sgalinski.de",
"license": "proprietary",
"version": "4.0.4",
"replace": {
"sgc-core": "self.version"
},
"require": {
"mnsami/composer-custom-directory-installer": "^1.1"
},
"require-dev": {
"roave/security-advisories": "dev-master"
}
"name": "sgalinski/sgc-core",
"description": "sgalinski command line interface",
"homepage": "https://www.sgalinski.de",
"license": "proprietary",
"version": "4.0.4",
"replace": {
"sgc-core": "self.version"
},
"require": {
"mnsami/composer-custom-directory-installer": "^1.1"
},
"require-dev": {
"roave/security-advisories": "dev-master"
}
}
......@@ -13,6 +13,6 @@ module.exports = class AdService {
static getRandomAd() {
const ads = require('./ads.json');
const adKeys = Object.keys(ads);
return ads[adKeys[Math.floor(Math.random()*adKeys.length)]];
return ads[adKeys[Math.floor(Math.random() * adKeys.length)]];
}
};
{
"sgalinskiProducts": {
"icon": "sgalinski.svg",
"title": "Did you already hear about our other products?",
"message": "We offer products and tools around TYPO3\nand the web, that help you to do your work more efficiently.\n\nVisit our website and learn more!",
"link": "https://www.sgalinski.de/products/"
}
"sgalinskiProducts": {
"icon": "sgalinski.svg",
"title": "Did you already hear about our other products?",
"message": "We offer products and tools around TYPO3\nand the web, that help you to do your work more efficiently.\n\nVisit our website and learn more!",
"link": "https://www.sgalinski.de/products/"
}
}
_script()
{
_script_commands=$(sgc shortlist)
_script() {
_script_commands=$(sgc shortlist)
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) )
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=($(compgen -W "${_script_commands}" -- ${cur}))
return 0
return 0
}
complete -o nospace -F _script sgc
#!/bin/bash
if [ ! -e "./sgc-core/.sgc_version" ]; then
echo -e "\033[0;31mThe .sgc-version file got lost. Please reinstall by executing the install.sh script.\033[0m";
exit 1;
echo -e "\033[0;31mThe .sgc-version file got lost. Please reinstall by executing the install.sh script.\033[0m"
exit 1
fi
. ./sgc-core/core/version.conf
. ./sgc-core/.sgc_version
if [ $SGC_VERSION != $INSTALLED_SGC_VERSION ]; then
echo -e "\033[0;31mYour installed sgc version does not match the one inside your project. Please execute the install.sh script inside the sgc-core folder. Run ./sgc-core/install.sh\033[0m";
exit 1;
if [ "$SGC_VERSION" != "$INSTALLED_SGC_VERSION" ]; then
echo -e "\033[0;31mYour installed sgc version does not match the one inside your project. Please execute the install.sh script inside the sgc-core folder. Run ./sgc-core/install.sh\033[0m"
exit 1
fi
function setNodeVersion {
function setNodeVersion() {
# the nvm config file will only exist on unix systems
if [ ! $OSTYPE == "msys" ]
then
if [ ! $OSTYPE == "msys" ]; then
. ~/.nvm/nvm.sh
fi
# include version config
. ./sgc-core/core/node.sh
if [ ! $OSTYPE == "msys" ]
then
if [ ! $OSTYPE == "msys" ]; then
# set node version
nvm use --delete-prefix ${nodeversion}
nvm use --delete-prefix "${nodeversion}"
else
# interestingly, setting the node version here will break on windows. for some reason the node and npm commands
# wont't be available anymore afterwards. tell the user instead.
if [ ! $(node -v) == "v${nodeversion}" ]
then
echo -e "\033[0;31mWrong node version! Please run 'nvm use ${nodeversion}\033[0m";
exit 1;
if [ ! $(node -v) == "v${nodeversion}" ]; then
echo -e "\033[0;31mWrong node version! Please run 'nvm use ${nodeversion}\033[0m"
exit 1
fi
fi
}
......@@ -41,27 +38,26 @@ COMMAND=$1
if [ "$COMMAND" == "shortlist" ]; then
taskList="server images css css:svg css:abovethefold images:uploaded js:compile js:qa js shortlist releaseExtension css:qa open"
if [ -e sgc-scripts ]
then
echo -e ${taskList} `ls sgc-scripts | grep .sh$ | cut -f 1 -d .`;
if [ -e sgc-scripts ]; then
echo -e "${taskList}" $(ls sgc-scripts | grep .sh$ | cut -f 1 -d .)
else
echo -e ${taskList}
echo -e "${taskList}"
fi
elif [ -e "sgc-core/core/modules/$COMMAND.sh" ]; then
setNodeVersion
./sgc-core/core/modules/$COMMAND.sh $@
"./sgc-core/core/modules/$COMMAND.sh" "$@"
elif [ -e "./sgc-scripts/$COMMAND.sh" ]; then
setNodeVersion
shift
./sgc-scripts/$COMMAND.sh $@
"./sgc-scripts/$COMMAND.sh" "$@"
elif [ -e "./sgc-scripts/$COMMAND.js" ]; then
setNodeVersion
node ./sgc-scripts/$COMMAND.js
node "./sgc-scripts/$COMMAND.js"
elif [ -e "./sgc-core/core/modules/$COMMAND.js" ]; then
setNodeVersion
node ./sgc-core/core/modules/$COMMAND.js $@
node "./sgc-core/core/modules/$COMMAND.js" "$@"
else
setNodeVersion
cd sgc-core
node ./core/run.js $@
cd sgc-core || exit
node ./core/run.js "$@"
fi
{
"directories": {
"basePath": "web/typo3conf/ext/",
"webPath": "typo3conf/ext/",
"css": "Resources/Public/StyleSheets",
"sass": "Resources/Public/Sass",
"cssSourceMaps": "Resources/Public/SourceMaps",
"javascriptSrc": "Resources/Public/JavaScript",
"javascriptDest": "Resources/Public/JavaScript/Dist",
"javascriptSourceMaps": "Resources/Public/SourceMaps",
"images": "Resources/Public/Images",
"sprites": "Resources/Public/Images/Sprites",
"svg": "Resources/Public/Images/Svg"
},
"abovethefold": [
{
"template": "web/typo3conf/ext/project_theme/Resources/Private/Templates/Abovethefold/Src/PageRenderTemplate.html",
"dest": "web/typo3conf/ext/project_theme/Resources/Private/Templates/Abovethefold/Dist/"
}
],
"js": {
"libraryPaths": [
"./web/typo3conf/ext/project_theme/node_modules"
],
"excludeFromQa": [
"!**/Extensions/**/*",
"!**/node_modules/**/*"
],
"pipeline": {
"dev": {
"uglify": false,
"renameToDotMin": true,
"polyfills": true,
"qa": true,
"sourceMaps": true
},
"prod": {
"uglify": true,
"renameToDotMin": true,
"polyfills": true,
"qa": false,
"sourceMaps": false
}
}
},
"css": {
"excludeFromQa": [
"!**/_svg.scss"
],
"pipeline": {
"dev": {
"cleanCss": false,
"renameToDotMin": true,
"qa": true,
"sourceMaps": true
},
"prod": {
"cleanCss": true,
"renameToDotMin": true,
"qa": false,
"sourceMaps": false
}
},
"svgIconPrefix": "icon-"
},
"supportedBrowsers": [
"> 2%",
"ie 11"
],
"images": {
"optimize": [
"web/fileadmin",
"web/uploads"
]
},
"extensions": [
"project_theme"
],
"logMessages": {
"imagesSuccess:uploaded": {
"level": "error",
"message": "Please make sure to clear the TYPO3 cache now, image hashes might have changed. Also make sure to run this command again after a few days."
}
},
"browsersync": {
"url": "https://www.website-base.dev",
"urlparams": "no_cache=1&disableScriptmerger=1"
},
"open": {
"all": [
"https://www.website-base.dev",
"https://www.website-base.dev/typo3"
]
}
"directories": {
"basePath": "web/typo3conf/ext/",
"webPath": "typo3conf/ext/",
"css": "Resources/Public/StyleSheets",
"sass": "Resources/Public/Sass",
"cssSourceMaps": "Resources/Public/SourceMaps",
"javascriptSrc": "Resources/Public/JavaScript",
"javascriptDest": "Resources/Public/JavaScript/Dist",
"javascriptSourceMaps": "Resources/Public/SourceMaps",
"images": "Resources/Public/Images",
"sprites": "Resources/Public/Images/Sprites",
"svg": "Resources/Public/Images/Svg"
},
"abovethefold": [
{
"template": "web/typo3conf/ext/project_theme/Resources/Private/Templates/Abovethefold/Src/PageRenderTemplate.html",
"dest": "web/typo3conf/ext/project_theme/Resources/Private/Templates/Abovethefold/Dist/"
}
],
"js": {
"libraryPaths": [
"./web/typo3conf/ext/project_theme/node_modules"
],
"excludeFromQa": [
"!**/Extensions/**/*",
"!**/node_modules/**/*"
],
"pipeline": {
"dev": {
"uglify": false,
"renameToDotMin": true,
"polyfills": true,
"qa": true,
"sourceMaps": true
},
"prod": {
"uglify": true,
"renameToDotMin": true,
"polyfills": true,
"qa": false,
"sourceMaps": false
}
}
},
"css": {
"excludeFromQa": [
"!**/_svg.scss"
],
"pipeline": {
"dev": {
"cleanCss": false,
"renameToDotMin": true,
"qa": true,
"sourceMaps": true
},
"prod": {
"cleanCss": true,
"renameToDotMin": true,
"qa": false,
"sourceMaps": false
}
},
"svgIconPrefix": "icon-"
},
"supportedBrowsers": [
"> 2%",
"ie 11"
],
"images": {
"optimize": [
"web/fileadmin",
"web/uploads"
]
},
"extensions": [
"project_theme"
],
"logMessages": {
"imagesSuccess:uploaded": {
"level": "error",
"message": "Please make sure to clear the TYPO3 cache now, image hashes might have changed. Also make sure to run this command again after a few days."
}
},
"browsersync": {
"url": "https://www.website-base.dev",
"urlparams": "no_cache=1&disableScriptmerger=1"
},
"open": {
"all": [
"https://www.website-base.dev",
"https://www.website-base.dev/typo3"
]
}
}
#!/usr/bin/env bash
{ # this ensures the entire script is downloaded #
nvm_has() {
type "$1" > /dev/null 2>&1
}
nvm_install_dir() {
command printf %s "${NVM_DIR:-"$HOME/.nvm"}"
}
nvm_latest_version() {
echo "v0.33.11"
}
nvm_profile_is_bash_or_zsh() {
local TEST_PROFILE
TEST_PROFILE="${1-}"
case "${TEST_PROFILE-}" in
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc")
return
;;
*)
return 1
;;
esac
}
#
# Outputs the location to NVM depending on:
# * The availability of $NVM_SOURCE
# * The method used ("script" or "git" in the script, defaults to "git")
# NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
#
nvm_source() {
local NVM_METHOD
NVM_METHOD="$1"
local NVM_SOURCE_URL
NVM_SOURCE_URL="$NVM_SOURCE"
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/bash_completion"
elif [ -z "$NVM_SOURCE_URL" ]; then
if [ "_$NVM_METHOD" = "_script" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
NVM_SOURCE_URL="https://github.com/creationix/nvm.git"
else
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
return 1
fi
fi
echo "$NVM_SOURCE_URL"
}
#
# Node.js version to install
#
nvm_node_version() {
echo "$NODE_VERSION"
}
nvm_download() {
if nvm_has "curl"; then
curl --compressed -q "$@"
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
-e 's/-L //' \
-e 's/--compressed //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
# shellcheck disable=SC2086
eval wget $ARGS
fi
}
install_nvm_from_git() {
local INSTALL_DIR
INSTALL_DIR="$(nvm_install_dir)"
if [ -d "$INSTALL_DIR/.git" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
command printf '\r=> '
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$(nvm_latest_version)" --depth=1 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
exit 1
}
else
# Cloning to $INSTALL_DIR
echo "=> Downloading nvm from git to '$INSTALL_DIR'"
command printf '\r=> '
mkdir -p "${INSTALL_DIR}"
if [ "$(ls -A "${INSTALL_DIR}")" ]; then
command git init "${INSTALL_DIR}" || {
echo >&2 'Failed to initialize nvm repo. Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" fetch origin tag "$(nvm_latest_version)" --depth=1 || {
echo >&2 'Failed to fetch origin with tags. Please report this!'
exit 2
}
else
command git -c advice.detachedHead=false clone "$(nvm_source)" -b "$(nvm_latest_version)" --depth=1 "${INSTALL_DIR}" || {
echo >&2 'Failed to clone nvm repo. Please report this!'
exit 2
}
fi
fi
command git -c advice.detachedHead=false --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)"
if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
else
echo >&2 "Your version of git is out of date. Please update it!"
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1
fi
fi
echo "=> Compressing and cleaning up git repository"
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" reflog expire --expire=now --all; then
echo >&2 "Your version of git is out of date. Please update it!"
fi
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --auto --aggressive --prune=now ; then
echo >&2 "Your version of git is out of date. Please update it!"
fi
return
}
#
# Automatically install Node.js
#
nvm_install_node() {
local NODE_VERSION_LOCAL
NODE_VERSION_LOCAL="$(nvm_node_version)"
if [ -z "$NODE_VERSION_LOCAL" ]; then
return 0
fi
echo "=> Installing Node.js version $NODE_VERSION_LOCAL"
nvm install "$NODE_VERSION_LOCAL"
local CURRENT_NVM_NODE
CURRENT_NVM_NODE="$(nvm_version current)"
if [ "$(nvm_version "$NODE_VERSION_LOCAL")" == "$CURRENT_NVM_NODE" ]; then
echo "=> Node.js version $NODE_VERSION_LOCAL has been successfully installed"
else
echo >&2 "Failed to install Node.js $NODE_VERSION_LOCAL"
fi
}
install_nvm_as_script() {
local INSTALL_DIR
INSTALL_DIR="$(nvm_install_dir)"
local NVM_SOURCE_LOCAL
NVM_SOURCE_LOCAL="$(nvm_source script)"
local NVM_EXEC_SOURCE
NVM_EXEC_SOURCE="$(nvm_source script-nvm-exec)"
local NVM_BASH_COMPLETION_SOURCE
NVM_BASH_COMPLETION_SOURCE="$(nvm_source script-nvm-bash-completion)"
# Downloading to $INSTALL_DIR
mkdir -p "$INSTALL_DIR"
if [ -f "$INSTALL_DIR/nvm.sh" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update the script"
else
echo "=> Downloading nvm as script to '$INSTALL_DIR'"
fi
nvm_download -s "$NVM_SOURCE_LOCAL" -o "$INSTALL_DIR/nvm.sh" || {
echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
return 1
} &
nvm_download -s "$NVM_EXEC_SOURCE" -o "$INSTALL_DIR/nvm-exec" || {
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
return 2
} &
nvm_download -s "$NVM_BASH_COMPLETION_SOURCE" -o "$INSTALL_DIR/bash_completion" || {
echo >&2 "Failed to download '$NVM_BASH_COMPLETION_SOURCE'"
return 2
} &
for job in $(jobs -p | command sort)
do
wait "$job" || return $?
done
chmod a+x "$INSTALL_DIR/nvm-exec" || {
echo >&2 "Failed to mark '$INSTALL_DIR/nvm-exec' as executable"
return 3
}
}
nvm_try_profile() {
if [ -z "${1-}" ] || [ ! -f "${1}" ]; then
return 1
fi
echo "${1}"
}
#
# Detect profile file if not specified as environment variable
# (eg: PROFILE=~/.myprofile)
# The echo'ed path is guaranteed to be an existing file
# Otherwise, an empty string is returned
#
nvm_detect_profile() {
if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then
echo "${PROFILE}"
return
fi
local DETECTED_PROFILE
DETECTED_PROFILE=''
if [ -n "${BASH_VERSION-}" ]; then
if [ -f "$HOME/.bashrc" ]; then
DETECTED_PROFILE="$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
DETECTED_PROFILE="$HOME/.bash_profile"
fi
elif [ -n "${ZSH_VERSION-}" ]; then
DETECTED_PROFILE="$HOME/.zshrc"
fi
if [ -z "$DETECTED_PROFILE" ]; then
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zshrc"
do
if DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; then
break
fi
done
fi
if [ ! -z "$DETECTED_PROFILE" ]; then
echo "$DETECTED_PROFILE"
fi
}