mirror of
https://github.com/opdavies/build-configs.git
synced 2025-02-08 16:15:03 +00:00
chore(run): replace justfiles with run files
This commit is contained in:
parent
3a86b4813a
commit
f5a8c691f0
|
@ -33,7 +33,7 @@ final class CreateListOfFilesToGenerate
|
||||||
new TemplateFile(data: 'astro/.envrc', name: '.envrc'),
|
new TemplateFile(data: 'astro/.envrc', name: '.envrc'),
|
||||||
new TemplateFile(data: 'astro/.gitignore', name: '.gitignore'),
|
new TemplateFile(data: 'astro/.gitignore', name: '.gitignore'),
|
||||||
new TemplateFile(data: 'astro/flake.nix', name: 'flake.nix'),
|
new TemplateFile(data: 'astro/flake.nix', name: 'flake.nix'),
|
||||||
new TemplateFile(data: 'astro/justfile', name: 'justfile'),
|
new TemplateFile(data: 'astro/run', name: 'run'),
|
||||||
new TemplateFile(data: 'astro/tsconfig.json', name: 'tsconfig.json'),
|
new TemplateFile(data: 'astro/tsconfig.json', name: 'tsconfig.json'),
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
@ -41,7 +41,7 @@ final class CreateListOfFilesToGenerate
|
||||||
case (strtolower(ProjectType::Fractal->name)):
|
case (strtolower(ProjectType::Fractal->name)):
|
||||||
$filesToGenerate = collect([
|
$filesToGenerate = collect([
|
||||||
new TemplateFile(data: 'fractal/.gitignore', name: '.gitignore'),
|
new TemplateFile(data: 'fractal/.gitignore', name: '.gitignore'),
|
||||||
new TemplateFile(data: 'fractal/justfile', name: 'justfile'),
|
new TemplateFile(data: 'fractal/run', name: 'run'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($isDocker) {
|
if ($isDocker) {
|
||||||
|
@ -55,6 +55,14 @@ final class CreateListOfFilesToGenerate
|
||||||
$filesToGenerate->push(new TemplateFile(data: 'fractal/.envrc', name: '.envrc'));
|
$filesToGenerate->push(new TemplateFile(data: 'fractal/.envrc', name: '.envrc'));
|
||||||
$filesToGenerate->push(new TemplateFile(data: 'fractal/flake.nix', name: 'flake.nix'));
|
$filesToGenerate->push(new TemplateFile(data: 'fractal/flake.nix', name: 'flake.nix'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Arr::get($configurationData, 'experimental.createGitHubActionsConfiguration', false) === true) {
|
||||||
|
$filesToGenerate[] = new TemplateFile(
|
||||||
|
data: 'fractal/.github/workflows/ci.yml',
|
||||||
|
name: 'ci.yml',
|
||||||
|
path: '.github/workflows',
|
||||||
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (strtolower(ProjectType::Drupal->name)):
|
case (strtolower(ProjectType::Drupal->name)):
|
||||||
|
@ -65,8 +73,8 @@ final class CreateListOfFilesToGenerate
|
||||||
new TemplateFile(data: 'drupal/.hadolint.yaml', name: '.hadolint.yaml'),
|
new TemplateFile(data: 'drupal/.hadolint.yaml', name: '.hadolint.yaml'),
|
||||||
new TemplateFile(data: 'drupal/Dockerfile', name: 'Dockerfile'),
|
new TemplateFile(data: 'drupal/Dockerfile', name: 'Dockerfile'),
|
||||||
new TemplateFile(data: 'drupal/docker-compose.yaml', name: 'docker-compose.yaml'),
|
new TemplateFile(data: 'drupal/docker-compose.yaml', name: 'docker-compose.yaml'),
|
||||||
new TemplateFile(data: 'drupal/justfile', name: 'justfile'),
|
|
||||||
new TemplateFile(data: 'drupal/phpstan.neon.dist', name: 'phpstan.neon.dist'),
|
new TemplateFile(data: 'drupal/phpstan.neon.dist', name: 'phpstan.neon.dist'),
|
||||||
|
new TemplateFile(data: 'drupal/run', name: 'run'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$extraDatabases = Arr::get($configurationData, 'database.extra_databases', []);
|
$extraDatabases = Arr::get($configurationData, 'database.extra_databases', []);
|
||||||
|
@ -120,7 +128,7 @@ final class CreateListOfFilesToGenerate
|
||||||
case (strtolower(ProjectType::Terraform->name)):
|
case (strtolower(ProjectType::Terraform->name)):
|
||||||
$filesToGenerate = collect([
|
$filesToGenerate = collect([
|
||||||
new TemplateFile(data: 'terraform/.gitignore', name: '.gitignore'),
|
new TemplateFile(data: 'terraform/.gitignore', name: '.gitignore'),
|
||||||
new TemplateFile(data: 'terraform/justfile', name: 'justfile'),
|
new TemplateFile(data: 'terraform/run', name: 'run'),
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,10 @@ final class GenerateConfigurationFiles
|
||||||
$this->filesystem->chmod("{$this->outputDir}/.githooks/prepare-commit-msg", 0755);
|
$this->filesystem->chmod("{$this->outputDir}/.githooks/prepare-commit-msg", 0755);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->filesystem->exists("{$this->outputDir}/run")) {
|
||||||
|
$this->filesystem->chmod("{$this->outputDir}/run", 0755);
|
||||||
|
}
|
||||||
|
|
||||||
return $next([$configurationDataDto, $filesToGenerate]);
|
return $next([$configurationDataDto, $filesToGenerate]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
# {{ managedText|raw }}
|
|
||||||
|
|
||||||
{% set isFlake = flake is defined %}
|
|
||||||
|
|
||||||
default:
|
|
||||||
@just --list
|
|
||||||
|
|
||||||
{% if not isFlake %}
|
|
||||||
# Start the project
|
|
||||||
start:
|
|
||||||
cp -v --no-clobber .env.example .env
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
# Stop the project
|
|
||||||
stop:
|
|
||||||
docker compose down
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
yarn *args:
|
|
||||||
{% if isFlake %}
|
|
||||||
{{ "just _exec yarn {{ args }}" | raw }}
|
|
||||||
{% else %}
|
|
||||||
{{ "just _exec node yarn {{ args }}" | raw }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# Enable or disable Git hooks
|
|
||||||
git-hooks command:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
case "{{ '{{ command }}'|raw }}" in
|
|
||||||
"on")
|
|
||||||
echo "Enabling Git hooks..."
|
|
||||||
git config core.hooksPath .githooks
|
|
||||||
;;
|
|
||||||
"off")
|
|
||||||
echo "Disabling Git hooks..."
|
|
||||||
git config --unset core.hooksPath
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Invalid argument. Must be either 'on' or 'off'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
_exec +args:
|
|
||||||
{% if flake is defined %}
|
|
||||||
{{ "nix develop --command {{ args }}" | raw }}
|
|
||||||
{% else %}
|
|
||||||
{{ "docker compose exec -T {{ args }}" | raw }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if flake is not defined %}
|
|
||||||
_run service command *args:
|
|
||||||
docker compose run \
|
|
||||||
--entrypoint {{ "{{ command }}"|raw }} \
|
|
||||||
--no-deps \
|
|
||||||
--rm \
|
|
||||||
-T \
|
|
||||||
{{ "{{ service }} {{ args }}"|raw }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# vim: ft=just
|
|
109
templates/astro/run.twig
Executable file
109
templates/astro/run.twig
Executable file
|
@ -0,0 +1,109 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# {{ managedText | raw }}
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
{% set isFlake = flake is defined %}
|
||||||
|
|
||||||
|
PATH="$PATH:./node_modules/.bin"
|
||||||
|
|
||||||
|
{% if not isFlake %}
|
||||||
|
# If we're running in CI we need to disable TTY allocation for docker compose
|
||||||
|
# commands that enable it by default, such as exec and run.
|
||||||
|
TTY="${TTY:-}"
|
||||||
|
if [[ ! -t 1 ]]; then
|
||||||
|
TTY="-T"
|
||||||
|
fi
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Remove and generated or temporary files.
|
||||||
|
function build {
|
||||||
|
astro build "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove and generated or temporary files.
|
||||||
|
function clean {
|
||||||
|
rm -fr build node_modules
|
||||||
|
touch build/.keep
|
||||||
|
}
|
||||||
|
|
||||||
|
# Disable Git hooks.
|
||||||
|
function git-hooks:off {
|
||||||
|
git config --unset core.hooksPath
|
||||||
|
}
|
||||||
|
|
||||||
|
# Enable Git hooks.
|
||||||
|
function git-hooks:on {
|
||||||
|
git config core.hooksPath .githooks
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a new Fractal component.
|
||||||
|
function fractal:new {
|
||||||
|
mkdir -p "components/${1}"
|
||||||
|
|
||||||
|
echo "name: ${1}" > "components/${1}/${1}.config.yml"
|
||||||
|
echo "${1}" > "components/${1}/${1}.twig"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display a list of all available commands.
|
||||||
|
function help {
|
||||||
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||||
|
|
||||||
|
compgen -A function | grep -v "^_" | cat -n
|
||||||
|
|
||||||
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start the project.
|
||||||
|
function start {
|
||||||
|
{% if not isFlake %}
|
||||||
|
cp -v --no-clobber .env.example .env
|
||||||
|
docker compose up -d
|
||||||
|
{% else %}
|
||||||
|
fractal start --sync
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sync {
|
||||||
|
clean
|
||||||
|
fractal build
|
||||||
|
|
||||||
|
aws s3 sync "build/." s3://"${BUCKET_NAME}" \
|
||||||
|
--acl "public-read" \
|
||||||
|
--cache-control max-age=3600
|
||||||
|
}
|
||||||
|
|
||||||
|
{% if not isFlake %}
|
||||||
|
# Run a command within the node container.
|
||||||
|
function cmd {
|
||||||
|
docker compose exec node yarn "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop the project
|
||||||
|
function stop {
|
||||||
|
docker compose down
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute yarn commands.
|
||||||
|
function yarn {
|
||||||
|
cmd node yarn "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _run {
|
||||||
|
local service="${1}"
|
||||||
|
local command="${2}"
|
||||||
|
|
||||||
|
docker compose run \
|
||||||
|
--entrypoint "${command}" \
|
||||||
|
--no-deps \
|
||||||
|
--rm \
|
||||||
|
-T \
|
||||||
|
"${service}" "${@}"
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||||
|
time "${@:-help}"
|
||||||
|
|
||||||
|
# vim: ft=bash
|
23
templates/drupal/.github/workflows/ci.yml.twig
vendored
23
templates/drupal/.github/workflows/ci.yml.twig
vendored
|
@ -17,30 +17,9 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install just
|
|
||||||
run: |
|
|
||||||
curl --proto '=https' \
|
|
||||||
--tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
|
|
||||||
|
|
||||||
- name: Checkout the code
|
- name: Checkout the code
|
||||||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||||
|
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: |
|
run: |
|
||||||
docker compose version
|
./run ci:test
|
||||||
|
|
||||||
docker network create traefik_proxy
|
|
||||||
|
|
||||||
cp --no-clobber .env.example .env
|
|
||||||
|
|
||||||
docker compose build --progress plain
|
|
||||||
|
|
||||||
docker compose up --detach
|
|
||||||
docker compose logs
|
|
||||||
|
|
||||||
just composer install --quiet --no-progress
|
|
||||||
|
|
||||||
just test --testdox --colors=always
|
|
||||||
|
|
||||||
just _run php phpcs
|
|
||||||
just _run php phpstan analyze --no-progress --memory-limit=512M
|
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
# {{ managedText | raw }}
|
|
||||||
|
|
||||||
default:
|
|
||||||
@just --list
|
|
||||||
|
|
||||||
# Start the project
|
|
||||||
start:
|
|
||||||
cp -v --no-clobber .env.example .env
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
# Stop the project
|
|
||||||
stop:
|
|
||||||
docker compose down
|
|
||||||
|
|
||||||
composer *args:
|
|
||||||
{{ "just _exec php composer {{ args }}" | raw }}
|
|
||||||
|
|
||||||
alias phpunit := test
|
|
||||||
|
|
||||||
test *args:
|
|
||||||
{{ "just _exec php phpunit --colors=always {{ args }}" | raw }}
|
|
||||||
|
|
||||||
drush *args:
|
|
||||||
{{ "just _exec php drush {{ args }}" | raw }}
|
|
||||||
|
|
||||||
install *args:
|
|
||||||
{{ "just _exec php drush site:install -y {{ args }}" | raw }}
|
|
||||||
|
|
||||||
# Enable or disable Git hooks
|
|
||||||
git-hooks command:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
case "{{ '{{ command }}'|raw }}" in
|
|
||||||
"on")
|
|
||||||
echo "Enabling Git hooks..."
|
|
||||||
git config core.hooksPath .githooks
|
|
||||||
;;
|
|
||||||
"off")
|
|
||||||
echo "Disabling Git hooks..."
|
|
||||||
git config --unset core.hooksPath
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Invalid argument. Must be either 'on' or 'off'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
{% if experimental.runGitHooksBeforePush %}
|
|
||||||
test-commit:
|
|
||||||
just _run php phpcs
|
|
||||||
just _run php phpstan analyze --no-progress --memory-limit=512M
|
|
||||||
|
|
||||||
just test --testdox --testsuite unit
|
|
||||||
just test --testdox --testsuite kernel
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
_exec +args:
|
|
||||||
{{ "docker compose exec -T {{ args }}" | raw }}
|
|
||||||
|
|
||||||
_run service command *args:
|
|
||||||
docker compose run \
|
|
||||||
--entrypoint {{ "{{ command }}"|raw }} \
|
|
||||||
--no-deps \
|
|
||||||
--rm \
|
|
||||||
-T \
|
|
||||||
{{ "{{ service }} {{ args }}"|raw }}
|
|
||||||
|
|
||||||
# vim: ft=just
|
|
118
templates/drupal/run.twig
Executable file
118
templates/drupal/run.twig
Executable file
|
@ -0,0 +1,118 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# {{ managedText | raw }}
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Run automated tests as part of the Continuous Integration (CI) pipeline.
|
||||||
|
function ci:test {
|
||||||
|
lint:dockerfile
|
||||||
|
|
||||||
|
docker compose version
|
||||||
|
|
||||||
|
docker network create traefik_proxy
|
||||||
|
|
||||||
|
cp --no-clobber .env.example .env
|
||||||
|
|
||||||
|
docker compose build --progress plain
|
||||||
|
|
||||||
|
docker compose up --detach
|
||||||
|
docker compose logs
|
||||||
|
|
||||||
|
composer install --quiet --no-progress
|
||||||
|
|
||||||
|
test --testdox
|
||||||
|
|
||||||
|
quality
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run a command within the php container.
|
||||||
|
function cmd {
|
||||||
|
docker compose exec php "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function coding-standards {
|
||||||
|
cmd phpcs "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function composer {
|
||||||
|
_exec php composer "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function drush {
|
||||||
|
_exec php drush "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function git-hooks:off {
|
||||||
|
git config --unset core.hooksPath
|
||||||
|
}
|
||||||
|
|
||||||
|
function git-hooks:on {
|
||||||
|
git config core.hooksPath .githooks
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display a list of all available commands.
|
||||||
|
function help {
|
||||||
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||||
|
|
||||||
|
compgen -A function | grep -v "^_" | cat -n
|
||||||
|
|
||||||
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
function lint:dockerfile {
|
||||||
|
docker container run --rm -i \
|
||||||
|
hadolint/hadolint hadolint --ignore DL3008 --ignore DL3059 -t style "${@}" - < Dockerfile
|
||||||
|
}
|
||||||
|
|
||||||
|
function quality {
|
||||||
|
coding-standards
|
||||||
|
static-analysis
|
||||||
|
}
|
||||||
|
|
||||||
|
function start {
|
||||||
|
cp -v --no-clobber .env.example .env
|
||||||
|
|
||||||
|
docker compose up -d
|
||||||
|
}
|
||||||
|
|
||||||
|
function static-analysis {
|
||||||
|
cmd phpstan --memory-limit=-1 --no-progress "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop {
|
||||||
|
docker compose down
|
||||||
|
}
|
||||||
|
|
||||||
|
function test {
|
||||||
|
_exec php phpunit --colors=always "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function test:commit {
|
||||||
|
test --testdox --testsuite functional
|
||||||
|
test --testdox --testsuite kernel
|
||||||
|
test --testdox --testsuite unit
|
||||||
|
|
||||||
|
quality
|
||||||
|
}
|
||||||
|
|
||||||
|
function _exec {
|
||||||
|
docker compose exec -T "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _run {
|
||||||
|
local service="${1}"
|
||||||
|
local command="${2}"
|
||||||
|
|
||||||
|
docker compose run \
|
||||||
|
--entrypoint "${command}" \
|
||||||
|
--no-deps \
|
||||||
|
--rm \
|
||||||
|
-T \
|
||||||
|
"${service}" "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||||
|
time "${@:-help}"
|
||||||
|
|
||||||
|
# vim: ft=bash
|
|
@ -1,82 +0,0 @@
|
||||||
# {{ managedText | raw }}
|
|
||||||
|
|
||||||
{% set isFlake = flake is defined %}
|
|
||||||
|
|
||||||
default:
|
|
||||||
@just --list
|
|
||||||
|
|
||||||
# Start the project
|
|
||||||
start:
|
|
||||||
{% if not isFlake %}
|
|
||||||
cp -v --no-clobber .env.example .env
|
|
||||||
docker compose up -d
|
|
||||||
{% else %}
|
|
||||||
yarn dev
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if not isFlake %}
|
|
||||||
# Stop the project
|
|
||||||
stop:
|
|
||||||
docker compose down
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
yarn *args:
|
|
||||||
{% if isFlake %}
|
|
||||||
{{ "just _exec yarn {{ args }}" | raw }}
|
|
||||||
{% else %}
|
|
||||||
{{ "just _exec node yarn {{ args }}" | raw }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
fractal *args:
|
|
||||||
{{ "just yarn fractal {{ args }}" | raw }}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -fr build
|
|
||||||
|
|
||||||
build *args:
|
|
||||||
{{ "just fractal build {{ args }}" | raw }}
|
|
||||||
|
|
||||||
sync: clean build
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -eux
|
|
||||||
aws s3 sync "build/." s3://"${BUCKET_NAME}" \
|
|
||||||
--acl "public-read" \
|
|
||||||
--cache-control max-age=3600
|
|
||||||
|
|
||||||
# Enable or disable Git hooks
|
|
||||||
git-hooks command:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
case "{{ '{{ command }}'|raw }}" in
|
|
||||||
"on")
|
|
||||||
echo "Enabling Git hooks..."
|
|
||||||
git config core.hooksPath .githooks
|
|
||||||
;;
|
|
||||||
"off")
|
|
||||||
echo "Disabling Git hooks..."
|
|
||||||
git config --unset core.hooksPath
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Invalid argument. Must be either 'on' or 'off'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
_exec +args:
|
|
||||||
{% if isFlake %}
|
|
||||||
{{ "nix develop --command {{ args }}" | raw }}
|
|
||||||
{% else %}
|
|
||||||
{{ "docker compose exec -T {{ args }}" | raw }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if not isFlake %}
|
|
||||||
_run service command *args:
|
|
||||||
docker compose run \
|
|
||||||
--entrypoint {{ "{{ command }}"|raw }} \
|
|
||||||
--no-deps \
|
|
||||||
--rm \
|
|
||||||
-T \
|
|
||||||
{{ "{{ service }} {{ args }}"|raw }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# vim: ft=just
|
|
113
templates/fractal/run.twig
Executable file
113
templates/fractal/run.twig
Executable file
|
@ -0,0 +1,113 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# {{ managedText | raw }}
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
{% set isFlake = flake is defined %}
|
||||||
|
|
||||||
|
PATH="$PATH:./node_modules/.bin"
|
||||||
|
|
||||||
|
{% if not isFlake %}
|
||||||
|
# If we're running in CI we need to disable TTY allocation for docker compose
|
||||||
|
# commands that enable it by default, such as exec and run.
|
||||||
|
TTY="${TTY:-}"
|
||||||
|
if [[ ! -t 1 ]]; then
|
||||||
|
TTY="-T"
|
||||||
|
fi
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Remove and generated or temporary files.
|
||||||
|
function build {
|
||||||
|
fractal build "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci:build {
|
||||||
|
build
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove and generated or temporary files.
|
||||||
|
function clean {
|
||||||
|
rm -fr build node_modules
|
||||||
|
touch build/.keep
|
||||||
|
}
|
||||||
|
|
||||||
|
# Disable Git hooks.
|
||||||
|
function git-hooks:off {
|
||||||
|
git config --unset core.hooksPath
|
||||||
|
}
|
||||||
|
|
||||||
|
# Enable Git hooks.
|
||||||
|
function git-hooks:on {
|
||||||
|
git config core.hooksPath .githooks
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a new Fractal component.
|
||||||
|
function fractal:new {
|
||||||
|
mkdir -p "components/${1}"
|
||||||
|
|
||||||
|
echo "name: ${1}" > "components/${1}/${1}.config.yml"
|
||||||
|
echo "${1}" > "components/${1}/${1}.twig"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display a list of all available commands.
|
||||||
|
function help {
|
||||||
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||||
|
|
||||||
|
compgen -A function | grep -v "^_" | cat -n
|
||||||
|
|
||||||
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start the project.
|
||||||
|
function start {
|
||||||
|
{% if not isFlake %}
|
||||||
|
cp -v --no-clobber .env.example .env
|
||||||
|
docker compose up -d
|
||||||
|
{% else %}
|
||||||
|
fractal start --sync
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sync {
|
||||||
|
clean
|
||||||
|
fractal build
|
||||||
|
|
||||||
|
aws s3 sync "build/." s3://"${BUCKET_NAME}" \
|
||||||
|
--acl "public-read" \
|
||||||
|
--cache-control max-age=3600
|
||||||
|
}
|
||||||
|
|
||||||
|
{% if not isFlake %}
|
||||||
|
# Run a command within the node container.
|
||||||
|
function cmd {
|
||||||
|
docker compose exec node yarn "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop the project
|
||||||
|
function stop {
|
||||||
|
docker compose down
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute yarn commands.
|
||||||
|
function yarn {
|
||||||
|
cmd node yarn "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _run {
|
||||||
|
local service="${1}"
|
||||||
|
local command="${2}"
|
||||||
|
|
||||||
|
docker compose run \
|
||||||
|
--entrypoint "${command}" \
|
||||||
|
--no-deps \
|
||||||
|
--rm \
|
||||||
|
-T \
|
||||||
|
"${service}" "${@}"
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||||
|
time "${@:-help}"
|
||||||
|
|
||||||
|
# vim: ft=bash
|
|
@ -1,25 +0,0 @@
|
||||||
# {{ managedText|raw }}
|
|
||||||
|
|
||||||
default:
|
|
||||||
@just --list
|
|
||||||
|
|
||||||
# Enable or disable Git hooks
|
|
||||||
git-hooks command:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
case "{{ '{{ command }}'|raw }}" in
|
|
||||||
"on")
|
|
||||||
echo "Enabling Git hooks..."
|
|
||||||
git config core.hooksPath .githooks
|
|
||||||
;;
|
|
||||||
"off")
|
|
||||||
echo "Disabling Git hooks..."
|
|
||||||
git config --unset core.hooksPath
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Invalid argument. Must be either 'on' or 'off'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# vim: ft=just
|
|
29
templates/terraform/run.twig
Executable file
29
templates/terraform/run.twig
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# {{ managedText | raw }}
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Disable Git hooks.
|
||||||
|
function git-hooks:off {
|
||||||
|
git config --unset core.hooksPath
|
||||||
|
}
|
||||||
|
|
||||||
|
# Enable Git hooks.
|
||||||
|
function git-hooks:on {
|
||||||
|
git config core.hooksPath .githooks
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display a list of all available commands.
|
||||||
|
function help {
|
||||||
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||||
|
|
||||||
|
compgen -A function | grep -v "^_" | cat -n
|
||||||
|
|
||||||
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||||
|
time "${@:-help}"
|
||||||
|
|
||||||
|
# vim: ft=bash
|
Loading…
Reference in a new issue