install stylua without cargo (#54)
* install stylua without cargo * move stylua to path * add required permissions for stylua * run stylua from utils dir
This commit is contained in:
3
.github/workflows/integration.yaml
vendored
3
.github/workflows/integration.yaml
vendored
@@ -39,7 +39,8 @@ jobs:
|
|||||||
- name: Setup tools
|
- name: Setup tools
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cargo install stylua
|
sudo apt install -y curl unzip --no-install-recommends
|
||||||
|
bash ./utils/install_stylua.sh
|
||||||
luarocks install luacheck
|
luarocks install luacheck
|
||||||
luarocks install vusted
|
luarocks install vusted
|
||||||
|
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -1,6 +1,6 @@
|
|||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
stylua --glob lua/**/*.lua -- lua
|
./utils/stylua --config-path stylua.toml ---glob lua/**/*.lua -- lua
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
@@ -12,13 +12,13 @@ test:
|
|||||||
|
|
||||||
.PHONY: pre-commit
|
.PHONY: pre-commit
|
||||||
pre-commit:
|
pre-commit:
|
||||||
stylua --glob lua/**/*.lua -- lua
|
./utils/stylua --config-path stylua.toml --glob lua/**/*.lua -- lua
|
||||||
luacheck lua
|
luacheck lua
|
||||||
vusted lua
|
vusted lua
|
||||||
|
|
||||||
.PHONY: integration
|
.PHONY: integration
|
||||||
integration:
|
integration:
|
||||||
stylua --check --glob lua/**/*.lua -- lua
|
./utils/stylua --config-path stylua.toml --check --glob lua/**/*.lua -- lua
|
||||||
luacheck lua
|
luacheck lua
|
||||||
vusted lua
|
vusted lua
|
||||||
|
|
||||||
|
|||||||
63
utils/install_stylua.sh
Normal file
63
utils/install_stylua.sh
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu pipefall
|
||||||
|
|
||||||
|
declare -r INSTALL_DIR="$PWD/utils"
|
||||||
|
declare -r RELEASE="0.10.0"
|
||||||
|
declare -r OS="linux"
|
||||||
|
# declare -r OS="$(uname -s)"
|
||||||
|
declare -r FILENAME="stylua-$RELEASE-$OS"
|
||||||
|
|
||||||
|
declare -a __deps=("curl" "unzip")
|
||||||
|
|
||||||
|
function check_deps() {
|
||||||
|
for dep in "${__deps[@]}"; do
|
||||||
|
if ! command -v "$dep" >/dev/null; then
|
||||||
|
echo "Missing depdendecy!"
|
||||||
|
echo "The \"$dep\" command was not found!. Please install and try again."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function download_stylua() {
|
||||||
|
local DOWNLOAD_DIR
|
||||||
|
local URL="https://github.com/JohnnyMorganz/StyLua/releases/download/v$RELEASE/$FILENAME.zip"
|
||||||
|
|
||||||
|
DOWNLOAD_DIR="$(mktemp -d)"
|
||||||
|
echo "Initiating download for Stylua v$RELEASE"
|
||||||
|
if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then
|
||||||
|
echo "Download failed. Check that the release/filename are correct."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installation in progress.."
|
||||||
|
unzip -q "$DOWNLOAD_DIR/$FILENAME.zip" -d "$DOWNLOAD_DIR"
|
||||||
|
|
||||||
|
if [ -f "$DOWNLOAD_DIR/stylua" ]; then
|
||||||
|
mv "$DOWNLOAD_DIR/stylua" "$INSTALL_DIR/stylua"
|
||||||
|
else
|
||||||
|
mv "$DOWNLOAD_DIR/$FILENAME/stylua" "$INSTALL_DIR/."
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod u+x "$INSTALL_DIR/stylua"
|
||||||
|
}
|
||||||
|
|
||||||
|
function verify_install() {
|
||||||
|
echo "Verifying installation.."
|
||||||
|
local DOWNLOADED_VER
|
||||||
|
DOWNLOADED_VER="$("$INSTALL_DIR/stylua" -V | awk '{ print $2 }')"
|
||||||
|
if [ "$DOWNLOADED_VER" != "$RELEASE" ]; then
|
||||||
|
echo "Mismatched version!"
|
||||||
|
echo "Expected: v$RELEASE but got v$DOWNLOADED_VER"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Verification complete!"
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
check_deps
|
||||||
|
download_stylua
|
||||||
|
verify_install
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user