From: patrick.gu Date: Tue, 24 Nov 2020 00:50:33 +0000 (-0800) Subject: Add dotenv-linter X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=b86d401b7546f4dd1e7476124a5153480f1b0778;p=webi-installers%2F.git Add dotenv-linter --- diff --git a/dotenv-linter/README.md b/dotenv-linter/README.md new file mode 100644 index 0000000..4306f86 --- /dev/null +++ b/dotenv-linter/README.md @@ -0,0 +1,81 @@ +--- +title: Dotenv Linter +homepage: https://dotenv-linter.github.io/ +tagline: | + dotenv-linter: ⚡️ Lightning-fast linter for .env files. Written in Rust 🦀 +--- + +### Updating `dotenv-linter` + +`webi dotenv-linter@stable` + +Use the `@beta` tag for pre-releases. + +#### Windows 10 + +On Windows 10 you'll get an error like this: + +> execution cannot proceed run because `vcruntime140.dll` was not found + +You need to download and install the +[Microsoft Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads). + +## Cheat Sheet + +> Dotenv Linter is a lightning-fast check for your `.env` files. +> It can rapidly detect and automatically fix issues. + +By default, `dotenv-linter` checks all `.env` files in the current directory: + +```bash +dotenv-linter +``` + +This is the same as the default behavior: + +```bash +dotenv-linter .env .env.* +``` + +To lint .env files recursively, use `-r`: + +```bash +dotenv-linter -r +``` + +For the complete usage, see the official [Dotenv Linter Usage Guide](https://dotenv-linter.github.io/#/usage). + +### How to automatically fix errors + +Use the `--fix` flag. + +```bash +dotenv-linter --fix +``` + +Backup files in the format of `.env_0000000000` will be created by default. +You can use `--no-backup` to skip this. + +### How to toggle linter rules + +You can turn off certain linter checks with `--skip` options, for example: + +```bash +dotenv-linter --skip QuoteCharacter --skip UnorderedKey +``` + +You can see the full list of linter rules with `dotenv-linter --show-checks`: + +```txt +DuplicatedKey +EndingBlankLine +ExtraBlankLine +IncorrectDelimiter +LeadingCharacter +KeyWithoutValue +LowercaseKey +QuoteCharacter +SpaceCharacter +TrailingWhitespace +UnorderedKey +``` diff --git a/dotenv-linter/install.ps1 b/dotenv-linter/install.ps1 new file mode 100644 index 0000000..26af173 --- /dev/null +++ b/dotenv-linter/install.ps1 @@ -0,0 +1,57 @@ +#!/usr/bin/env pwsh + +######################### +# Install dotenv-linter # +######################### + +# Every package should define these variables +$pkg_cmd_name = "dotenv-linter" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\dotenv-linter.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\dotenv-linter-v$Env:WEBI_VERSION\bin\dotenv-linter.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\dotenv-linter-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\dotenv-linter-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + echo "Downloading dotenv-linter from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing dotenv-linter" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\dotenv-linter-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\dotenv-linter.exe" -Recurse -ErrorAction Ignore + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force + Move-Item -Path ".\dotenv-linter.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/dotenv-linter/install.sh b/dotenv-linter/install.sh new file mode 100644 index 0000000..9bff300 --- /dev/null +++ b/dotenv-linter/install.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +{ + set -e + set -u + + ######################### + # Install dotenv-linter # + ######################### + + # Every package should define these 6 variables + pkg_cmd_name="dotenv-linter" + + pkg_dst_cmd="$HOME/.local/bin/dotenv-linter" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/dotenv-linter-v$WEBI_VERSION/bin/dotenv-linter" + pkg_src_dir="$HOME/.local/opt/dotenv-linter-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + # pkg_install must be defined by every package + pkg_install() { + # ~/.local/opt/dotenv-linter-v0.99.9/bin + mkdir -p "$(dirname $pkg_src_cmd)" + + # mv ./dotenv-linter-*/dotenv-linter ~/.local/opt/dotenv-linter-v0.99.9/bin/dotenv-linter + mv ./dotenv-linter "$pkg_src_cmd" + } + + # pkg_get_current_version is recommended, but (soon) not required + pkg_get_current_version() { + # 'dotenv-linter --version' has output in this format: + # dotenv-linter 0.99.9 (rev abcdef0123) + # This trims it down to just the version number: + # 0.99.9 + echo $(dotenv-linter --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2) + } + +} diff --git a/dotenv-linter/releases.js b/dotenv-linter/releases.js new file mode 100644 index 0000000..f30da76 --- /dev/null +++ b/dotenv-linter/releases.js @@ -0,0 +1,20 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'dotenv-linter'; +var repo = 'dotenv-linter'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + // just select the first 5 for demonstration + all.releases = all.releases.slice(0, 5); + console.info(JSON.stringify(all, null, 2)); + }); +}