Add dotenv-linter

This commit is contained in:
patrick.gu
2020-12-02 13:14:56 -07:00
committed by AJ ONeal
parent 0aa421a042
commit b86d401b75
4 changed files with 197 additions and 0 deletions
+81
View File
@@ -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
```
+57
View File
@@ -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
+39
View File
@@ -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)
}
}
+20
View File
@@ -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));
});
}