mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-05-03 07:16:45 +00:00
add dotenv
This commit is contained in:
59
dotenv/README.md
Normal file
59
dotenv/README.md
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: dotenv
|
||||
homepage: https://github.com/therootcompany/dotenv
|
||||
tagline: |
|
||||
dotenv: a cross-platform tool to load a .env and run a command.
|
||||
---
|
||||
|
||||
## Updating `dotenv`
|
||||
|
||||
```bash
|
||||
webi dotenv@stable
|
||||
```
|
||||
|
||||
Use the `@beta` tag for pre-releases, or `@x.y.z` for a specific version.
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
> dotenv makes it easy to run a command with a set of ENVs (environment
|
||||
> variables) from a .env file. It works cross platform, and with any programming
|
||||
> environment (Node.js, Go, Rust, Ruby, Python, etc)
|
||||
|
||||
```bash
|
||||
# Usage: dotenv [-f .env.alt] -- <command> [arguments]
|
||||
|
||||
# Example:
|
||||
dotenv -f .env -- node server.js --debug
|
||||
```
|
||||
|
||||
## How Precedence Works
|
||||
|
||||
1. command line flags
|
||||
- ex: `--port 8080`
|
||||
2. existing environment variables
|
||||
- ex: `export PORT=8080` or `env PORT=8080 mycommand`
|
||||
3. first-loaded wins for multiple or cascading .env.\* files
|
||||
- ex: `dotenv -f .env,.env.local`
|
||||
|
||||
## ENV syntax
|
||||
|
||||
```txt
|
||||
# comments and blank lines are ignored
|
||||
|
||||
# you can use quotes of either style
|
||||
FOO=bar
|
||||
FOO2="bar2 bar3"
|
||||
FOO3='bar2 bar3'
|
||||
|
||||
# 'export' will be trimmed and ignored
|
||||
# (yay for bash compatibility)
|
||||
export FOOBAR=excellent
|
||||
```
|
||||
|
||||
## Why --?
|
||||
|
||||
The `--` is a common convention for arguments parsers to let them know that
|
||||
everything after the `--` should be treated as an argument (a word) rather than
|
||||
a flag (not something like `--help`).
|
||||
|
||||
You should use this whenever one command runs another command.
|
||||
57
dotenv/install.ps1
Normal file
57
dotenv/install.ps1
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
##################
|
||||
# Install dotenv #
|
||||
##################
|
||||
|
||||
# Every package should define these variables
|
||||
$pkg_cmd_name = "dotenv"
|
||||
|
||||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\dotenv.exe"
|
||||
$pkg_dst = "$pkg_dst_cmd"
|
||||
|
||||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\dotenv-v$Env:WEBI_VERSION\bin\dotenv.exe"
|
||||
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\dotenv-v$Env:WEBI_VERSION\bin"
|
||||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\dotenv-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 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"
|
||||
|
||||
# TODO: create package-specific temp directory
|
||||
# Enter tmp
|
||||
pushd .local\tmp
|
||||
|
||||
# Remove any leftover tmp cruft
|
||||
Remove-Item -Path ".\dotenv-v*" -Recurse -ErrorAction Ignore
|
||||
Remove-Item -Path ".\dotenv.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
|
||||
Move-Item -Path ".\dotenv.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
|
||||
42
dotenv/install.sh
Normal file
42
dotenv/install.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
function __init_dotenv() {
|
||||
set -e
|
||||
set -u
|
||||
|
||||
##################
|
||||
# Install dotenv #
|
||||
##################
|
||||
|
||||
# Every package should define these 6 variables
|
||||
pkg_cmd_name="dotenv"
|
||||
|
||||
pkg_dst_cmd="$HOME/.local/bin/dotenv"
|
||||
pkg_dst="$pkg_dst_cmd"
|
||||
|
||||
pkg_src_cmd="$HOME/.local/opt/dotenv-v$WEBI_VERSION/bin/dotenv"
|
||||
pkg_src_dir="$HOME/.local/opt/dotenv-v$WEBI_VERSION"
|
||||
pkg_src="$pkg_src_cmd"
|
||||
|
||||
pkg_install() {
|
||||
# $HOME/.local/opt/dotenv-v1.0.0/bin
|
||||
mkdir -p "$pkg_src_bin"
|
||||
|
||||
# mv ./dotenv* "$HOME/.local/opt/dotenv-v1.0.0/bin/dotenv"
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
|
||||
|
||||
# chmod a+x "$HOME/.local/xbin/dotenv-v1.0.0/bin/dotenv"
|
||||
chmod a+x "$pkg_src_cmd"
|
||||
}
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'dotenv version' has output in this format:
|
||||
# v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
|
||||
# This trims it down to just the version number:
|
||||
# 2.0.0
|
||||
echo "$(dotenv --version 2>/dev/null | head -n 1 | cut -d' ' -f2 | sed 's:^v::')"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
__init_dotenv
|
||||
19
dotenv/releases.js
Normal file
19
dotenv/releases.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var github = require('../_common/github.js');
|
||||
var owner = 'therootcompany';
|
||||
var repo = 'dotenv';
|
||||
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
// remove checksums and .deb
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user