Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed May 11, 2021
0 parents commit 8c4d295
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
disable=SC1091
disable=SC2155
disable=SC1090
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# glue-store

My personal store for [glue](https://github.com/eankeen/glue)

The contents of each folder is copied to the `auto` subdirectory for any project you manage with `glue`

## Usage

Glue doesn't have a distribution channel yet, so invoke it in a
cloned repository directory

```sh
# Example ($PWD is eankeen/glue-example)
../glue/glue.sh sync && ../glue/glue.sh cmd NodeJS_Server.build
```
27 changes: 27 additions & 0 deletions actions.bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# shellcheck shell=sh

# note 1
# the variables GLUE_ACTIONS_DIR
# GLUE_COMMANDS_DIR, and GLUE_CONFIG_DIR,
# will all be incorrect when sourcing this file. I don't
# change them because I don't use them on the first pass
# of any of the bootstrap files

# shellcheck disable=SC2016
printf "%s" '
if [[ $GLUE_IS_AUTO == yes ]]; then
if [ -f "$GLUE_ACTIONS_DIR"/../util/bootstrap.sh ]; then
source "$GLUE_ACTIONS_DIR"/../util/bootstrap.sh
else
# see note 1
[[ -f $GLUE_ACTIONS_DIR/util/bootstrap.sh ]] && source "$GLUE_ACTIONS_DIR/util/bootstrap.sh"
fi
else
if [[ -f $GLUE_ACTIONS_DIR/util/bootstrap.sh ]]; then
source "$GLUE_ACTIONS_DIR/util/bootstrap.sh"
else
# see note 1
[[ -f $GLUE_ACTIONS_DIR/auto/util/bootstrap.sh ]] && source "$GLUE_ACTIONS_DIR/auto/util/bootstrap.sh"
fi
fi
'
9 changes: 9 additions & 0 deletions actions/auto/do-npm-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# shellcheck shell=sh

eval "$GLUE_ACTIONS_BOOTSTRAP"
bootstrap

# glue requireConfigs(prettier.config.js)

prettierConfig="$(util_get_config "prettier.config.js")"
ln -sfT "$prettierConfig" "$GLUE_CONFIGS_DIR/prettier.config.js"
63 changes: 63 additions & 0 deletions actions/auto/util/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# shellcheck shell=bash

bootstrap() {
shopt -q nullglob
local shoptExitStatus="$?"
shopt -s nullglob

# paths of all the files to source
local -a filesToSource=()

local utilDirAuto
if [[ $GLUE_IS_AUTO = yes ]]; then
utilDirAuto="$GLUE_ACTIONS_DIR/util"
else
utilDirAuto="$GLUE_ACTIONS_DIR/auto/util"
fi

local utilDirOverride
if [[ $GLUE_IS_AUTO = yes ]]; then
utilDirOverride="$GLUE_ACTIONS_DIR/../util"
else
utilDirOverride="$GLUE_ACTIONS_DIR/util"
fi

# Add file in 'util' to filesToSource, ensuring priority of 'override' scripts

local file possibleFileBasename
for file in "$utilDirOverride"/*?.sh; do
echo "added: $file"
filesToSource+=("$file")
done

for possibleFile in "$utilDirAuto"/*?.sh; do
possibleFileBasename="${possibleFile##*/}"

if [[ $possibleFileBasename == 'bootstrap.sh' ]]; then
continue
fi

# loop over exiting files that we're going to source
# and ensure 'possibleFile' is not already there
local alreadyThere=no
for file in "${filesToSource[@]}"; do
fileBasename="${file##*/}"

# if the file is not included (which means it's not
# already covered by 'override'), add it
if [[ $fileBasename == "$possibleFileBasename" ]]; then
alreadyThere=yes
fi
done

if [[ $alreadyThere == no ]]; then
filesToSource+=("$possibleFile")
fi
done

(( shoptExitStatus != 0 )) && shopt -u nullglob

for file in "${filesToSource[@]}"; do
source "$file"
done
}
27 changes: 27 additions & 0 deletions commands.bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# shellcheck shell=sh

# note 1
# the variables GLUE_ACTIONS_DIR
# GLUE_COMMANDS_DIR, and GLUE_CONFIG_DIR,
# will all be incorrect when sourcing this file. I don't
# change them because I don't use them on the first pass
# of any of the bootstrap files

# shellcheck disable=SC2016
printf "%s" '
if [[ $GLUE_IS_AUTO == yes ]]; then
if [ -f "$GLUE_COMMANDS_DIR"/../util/bootstrap.sh ]; then
source "$GLUE_COMMANDS_DIR"/../util/bootstrap.sh
else
# see note 1
[[ -f $GLUE_COMMANDS_DIR/util/bootstrap.sh ]] && source "$GLUE_COMMANDS_DIR/util/bootstrap.sh"
fi
else
if [[ -f $GLUE_COMMANDS_DIR/util/bootstrap.sh ]]; then
source "$GLUE_COMMANDS_DIR/util/bootstrap.sh"
else
# see note 1
[[ -f $GLUE_COMMANDS_DIR/auto/util/bootstrap.sh ]] && source "$GLUE_COMMANDS_DIR/auto/util/bootstrap.sh"
fi
fi
'
8 changes: 8 additions & 0 deletions commands/auto/NodeJS_Server.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

eval "$GLUE_COMMANDS_BOOTSTRAP"
bootstrap

# glue requireActions(do-npm-build)

log_info "Content"
63 changes: 63 additions & 0 deletions commands/auto/util/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# shellcheck shell=bash

bootstrap() {
shopt -q nullglob
local shoptExitStatus="$?"
shopt -s nullglob

# paths of all the files to source
local -a filesToSource=()

local utilDirAuto
if [[ $GLUE_IS_AUTO = yes ]]; then
utilDirAuto="$GLUE_COMMANDS_DIR/util"
else
utilDirAuto="$GLUE_COMMANDS_DIR/auto/util"
fi

local utilDirOverride
if [[ $GLUE_IS_AUTO = yes ]]; then
utilDirOverride="$GLUE_COMMANDS_DIR/../util"
else
utilDirOverride="$GLUE_COMMANDS_DIR/util"
fi

# Add file in 'util' to filesToSource, ensuring priority of 'override' scripts

local file possibleFileBasename
for file in "$utilDirOverride"/*?.sh; do
echo "added: $file"
filesToSource+=("$file")
done

for possibleFile in "$utilDirAuto"/*?.sh; do
possibleFileBasename="${possibleFile##*/}"

if [[ $possibleFileBasename == 'bootstrap.sh' ]]; then
continue
fi

# loop over exiting files that we're going to source
# and ensure 'possibleFile' is not already there
local alreadyThere=no
for file in "${filesToSource[@]}"; do
fileBasename="${file##*/}"

# if the file is not included (which means it's not
# already covered by 'override'), add it
if [[ $fileBasename == "$possibleFileBasename" ]]; then
alreadyThere=yes
fi
done

if [[ $alreadyThere == no ]]; then
filesToSource+=("$possibleFile")
fi
done

(( shoptExitStatus != 0 )) && shopt -u nullglob

for file in "${filesToSource[@]}"; do
source "$file"
done
}
48 changes: 48 additions & 0 deletions commands/auto/util/util.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# shellcheck shell=sh

trap sigint INT
sigint() {
die 'Received SIGINT'
}

die() {
log_error "${*-'die: '}. Exiting"
exit 1
}

log_info() {
printf "\033[0;34m%s\033[0m\n" "Info: $*"
}

log_warn() {
printf "\033[1;33m%s\033[0m\n" "Warn: $*" >&2
}

log_error() {
printf "\033[0;31m%s\033[0m\n" "Error: $*" >&2
}

util_get_working_dir() {
while [ ! -f "glue.sh" ] && [ "$PWD" != / ]; do
cd ..
done

if [ "$PWD" = / ]; then
die 'No glue config file found in current or parent paths'
fi

printf "%s" "$PWD"
}

util_get_config() {
configFile="$1"

# if an override exists (above the 'auto' directory), use that
if [ -f "$(dirname "$configDir")/$configFile" ]; then
printf "%s" "$configDir/$configFile"
elif [ -f "$configDir/$configFile" ]; then
printf "%s" "$configDir/$configFile"
else
die 'No config file found. This is an issue with the glue store'
fi
}
2 changes: 2 additions & 0 deletions configs/auto/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}

0 comments on commit 8c4d295

Please sign in to comment.