Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test ./tests/validate.sh
hello ./src/hello.sh
env ./src/env.sh
manifest ./src/manifest.sh
python-info PYTHONPATH=lib/python python -m base_demo_cli
python-info ./bin/base-demo-python-info

$ basectl run base-demo hello
hello from base-demo
Expand All @@ -80,6 +80,8 @@ because activation sources `.base/activate.sh` into the project shell.
for `basectl run`.
- `lib/python/base_demo_cli` is a tiny Python command target that runs inside
the Base-managed project environment.
- `bin/base-demo-python-info` is the Bash launcher that delegates the Python
package to `base-wrapper`.
- `demo/demo.sh` is the interactive walkthrough.
- `tests/validate.sh` verifies that the repository baseline is intact.

Expand Down
2 changes: 1 addition & 1 deletion base_manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ commands:
hello: ./src/hello.sh
env: ./src/env.sh
manifest: ./src/manifest.sh
python-info: PYTHONPATH=lib/python python -m base_demo_cli
python-info: ./bin/base-demo-python-info

test:
command: ./tests/validate.sh
Expand Down
20 changes: 20 additions & 0 deletions bin/base-demo-python-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

if [[ -z "${BASE_HOME:-}" ]]; then
printf 'ERROR: BASE_HOME is not set. Run this through basectl or an activated Base shell.\n' >&2
exit 1
fi

if [[ -z "${BASE_PROJECT_ROOT:-}" ]]; then
printf 'ERROR: BASE_PROJECT_ROOT is not set. Run this through basectl or an activated Base shell.\n' >&2
exit 1
fi

if [[ -n "${PYTHONPATH:-}" ]]; then
PYTHONPATH="$BASE_PROJECT_ROOT/lib/python:$PYTHONPATH"
else
PYTHONPATH="$BASE_PROJECT_ROOT/lib/python"
fi
export PYTHONPATH

exec "$BASE_HOME/bin/base-wrapper" --project "${BASE_PROJECT:-base-demo}" base_demo_cli "$@"
18 changes: 12 additions & 6 deletions demo/demo.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail

BASE_DEMO_PROJECT="${BASE_PROJECT:-base-demo}"
BASE_DEMO_ROOT="${BASE_PROJECT_ROOT:-}"
Expand All @@ -19,13 +18,19 @@ demo_project_root() {
cd -- "$(demo_script_dir)/.." && pwd -P
}

BASE_DEMO_ROOT="$(demo_project_root)"
BASE_DEMO_ROOT="$(demo_project_root)" || {
printf 'ERROR: Unable to resolve base-demo project root.\n' >&2
exit 1
}

demo_workspace_root() {
cd -- "$BASE_DEMO_ROOT/.." && pwd -P
}

BASE_DEMO_WORKSPACE="$(demo_workspace_root)"
BASE_DEMO_WORKSPACE="$(demo_workspace_root)" || {
printf 'ERROR: Unable to resolve base-demo workspace root.\n' >&2
exit 1
}

usage() {
cat <<'EOF'
Expand Down Expand Up @@ -120,6 +125,7 @@ project_shape_step() {
step 1 "Project Shape"
run_command test -f "$BASE_DEMO_ROOT/base_manifest.yaml"
run_command test -f "$BASE_DEMO_ROOT/Brewfile"
run_command test -x "$BASE_DEMO_ROOT/bin/base-demo-python-info"
run_command test -x "$BASE_DEMO_ROOT/src/hello.sh"
run_command test -x "$BASE_DEMO_ROOT/src/env.sh"
run_command test -x "$BASE_DEMO_ROOT/src/manifest.sh"
Expand All @@ -133,7 +139,7 @@ manifest_step() {
run_command grep -n "hello: ./src/hello.sh" "$BASE_DEMO_ROOT/base_manifest.yaml"
run_command grep -n "env: ./src/env.sh" "$BASE_DEMO_ROOT/base_manifest.yaml"
run_command grep -n "manifest: ./src/manifest.sh" "$BASE_DEMO_ROOT/base_manifest.yaml"
run_command grep -n "python-info: PYTHONPATH=lib/python python -m base_demo_cli" "$BASE_DEMO_ROOT/base_manifest.yaml"
run_command grep -n "python-info: ./bin/base-demo-python-info" "$BASE_DEMO_ROOT/base_manifest.yaml"
run_command grep -n "command: ./tests/validate.sh" "$BASE_DEMO_ROOT/base_manifest.yaml"
run_command grep -n "script: ./demo/demo.sh" "$BASE_DEMO_ROOT/base_manifest.yaml"
pause
Expand All @@ -142,7 +148,7 @@ manifest_step() {
activation_step() {
step 5 "Project Activation Source"
# shellcheck source=/dev/null
source "$BASE_DEMO_ROOT/.base/activate.sh"
source "$BASE_DEMO_ROOT/.base/activate.sh" || return 1
printf 'BASE_DEMO_ENV=%s\n' "${BASE_DEMO_ENV:-unset}"
printf 'BASE_DEMO_ACTIVATED=%s\n' "${BASE_DEMO_ACTIVATED:-unset}"
printf 'BASE_DEMO_PROJECT_KIND=%s\n' "${BASE_DEMO_PROJECT_KIND:-unset}"
Expand Down Expand Up @@ -240,7 +246,7 @@ main() {
return "$status"
}

cd -- "$BASE_DEMO_ROOT"
cd -- "$BASE_DEMO_ROOT" || return 1
intro
project_shape_step
manifest_step
Expand Down
1 change: 0 additions & 1 deletion src/env.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail

print_var() {
local name="$1"
Expand Down
1 change: 0 additions & 1 deletion src/hello.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail

printf 'hello from base-demo\n'
printf 'BASE_PROJECT=%s\n' "${BASE_PROJECT:-unset}"
Expand Down
1 change: 0 additions & 1 deletion src/manifest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail

manifest="${BASE_PROJECT_MANIFEST:-base_manifest.yaml}"

Expand Down
2 changes: 1 addition & 1 deletion tests/demo_test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ case "$*" in
printf 'hello ./src/hello.sh\n'
printf 'env ./src/env.sh\n'
printf 'manifest ./src/manifest.sh\n'
printf 'python-info PYTHONPATH=lib/python python -m base_demo_cli\n'
printf 'python-info ./bin/base-demo-python-info\n'
;;
run\ base-demo\ --workspace\ *\ hello)
printf 'hello from base-demo\n'
Expand Down
6 changes: 3 additions & 3 deletions tests/validate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail

required_files=(
README.md
Expand All @@ -10,6 +9,7 @@ required_files=(
base_manifest.yaml
Brewfile
.base/activate.sh
bin/base-demo-python-info
src/hello.sh
src/env.sh
src/manifest.sh
Expand All @@ -27,7 +27,7 @@ for file in "${required_files[@]}"; do
}
done

for executable in tests/validate.sh .base/activate.sh src/hello.sh src/env.sh src/manifest.sh demo/demo.sh; do
for executable in tests/validate.sh .base/activate.sh bin/base-demo-python-info src/hello.sh src/env.sh src/manifest.sh demo/demo.sh; do
[[ -x "$executable" ]] || {
printf 'Required file is not executable: %s\n' "$executable" >&2
exit 1
Expand Down Expand Up @@ -64,7 +64,7 @@ grep -Fq 'manifest: ./src/manifest.sh' base_manifest.yaml || {
exit 1
}

grep -Fq 'python-info: PYTHONPATH=lib/python python -m base_demo_cli' base_manifest.yaml || {
grep -Fq 'python-info: ./bin/base-demo-python-info' base_manifest.yaml || {
printf 'base_manifest.yaml does not declare the python-info command.\n' >&2
exit 1
}
Expand Down
Loading