-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn examples into template, and add docker examples.
- Loading branch information
1 parent
c0c03c3
commit a7996ae
Showing
11 changed files
with
291 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# WARNING: This file is auto-generated by snipinator. Do not edit directly. | ||
# SOURCE: `examples/simple_example.sh.jinja2`. | ||
|
||
#!/bin/bash | ||
# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425 | ||
set -e -x -v -u -o pipefail | ||
set +v | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # No Color | ||
PS4="${GREEN}$ ${NC}" | ||
|
||
EXCALIDRAW_BRUTE_EXPORT_CLI_URL=${EXCALIDRAW_BRUTE_EXPORT_CLI_URL:-} | ||
if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL}" ]]; then | ||
echo -e "${RED}EXCALIDRAW_BRUTE_EXPORT_CLI_URL is not set${NC}" | ||
exit 1 | ||
fi | ||
|
||
|
||
|
||
# Don't run this in act/GH actions because act doesn't play with with nested | ||
# docker; the paths mess up. | ||
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then | ||
echo -e "${YELLOW}This script is not meant to be run in GitHub Actions.${NC}" | ||
exit 0 | ||
fi | ||
|
||
: ECHO_SNIPPET_START | ||
# SNIPPET_START | ||
docker build -t my-excalidraw-brute-export-cli-image . | ||
|
||
# /data in the docker image is the working directory, so paths are simpler. | ||
docker run --rm --tty \ | ||
-u "$(id -u):$(id -g)" \ | ||
-v "${PWD}:/data" \ | ||
my-excalidraw-brute-export-cli-image \ | ||
-i ./examples/simple.excalidraw \ | ||
--background 1 \ | ||
--embed-scene 1 \ | ||
--dark-mode 0 \ | ||
--scale 1 \ | ||
--format png \ | ||
-o "./examples/simple_example_output.png" | ||
|
||
ls "./examples/simple_example_output.png" | ||
|
||
# SNIPPET_END | ||
: ECHO_SNIPPET_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
# WARNING: This file is auto-generated by snipinator. Do not edit directly. | ||
# SOURCE: `examples/simple_example.sh.jinja2`. | ||
|
||
#!/bin/bash | ||
# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425 | ||
set -e -x -v -u -o pipefail | ||
set +v | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # No Color | ||
PS4="${GREEN}$ ${NC}" | ||
|
||
EXCALIDRAW_BRUTE_EXPORT_CLI_URL=${EXCALIDRAW_BRUTE_EXPORT_CLI_URL:-} | ||
if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL}" ]]; then | ||
echo -e "${RED}EXCALIDRAW_BRUTE_EXPORT_CLI_URL is not set${NC}" | ||
exit 1 | ||
fi | ||
|
||
|
||
|
||
# Don't run this in act/GH actions because act doesn't play with with nested | ||
# docker; the paths mess up. | ||
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then | ||
echo -e "${YELLOW}This script is not meant to be run in GitHub Actions.${NC}" | ||
exit 0 | ||
fi | ||
|
||
: ECHO_SNIPPET_START | ||
# SNIPPET_START | ||
# Use the published images at ghcr.io/realazthat/snipinator. | ||
# /data in the docker image is the working directory, so paths are simpler. | ||
docker run --rm --tty \ | ||
-u "$(id -u):$(id -g)" \ | ||
-v "${PWD}:/data" \ | ||
ghcr.io/realazthat/excalidraw-brute-export-cli:v0.3.2 \ | ||
-i ./examples/simple.excalidraw \ | ||
--background 1 \ | ||
--embed-scene 1 \ | ||
--dark-mode 0 \ | ||
--scale 1 \ | ||
--format png \ | ||
-o "./examples/simple_example_output.png" | ||
|
||
ls "./examples/simple_example_output.png" | ||
|
||
# SNIPPET_END | ||
: ECHO_SNIPPET_END |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
# WARNING: This file is auto-generated by snipinator. Do not edit directly. | ||
# SOURCE: `examples/simple_example.sh.jinja2`. | ||
|
||
#!/bin/bash | ||
# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425 | ||
set -e -x -v -u -o pipefail | ||
set +v | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # No Color | ||
PS4="${GREEN}$ ${NC}" | ||
|
||
EXCALIDRAW_BRUTE_EXPORT_CLI_URL=${EXCALIDRAW_BRUTE_EXPORT_CLI_URL:-} | ||
if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL}" ]]; then | ||
echo -e "${RED}EXCALIDRAW_BRUTE_EXPORT_CLI_URL is not set${NC}" | ||
exit 1 | ||
fi | ||
|
||
: ECHO_SNIPPET_START | ||
# SNIPPET_START | ||
npx excalidraw-brute-export-cli \ | ||
-i ./examples/simple.excalidraw \ | ||
--background 1 \ | ||
--embed-scene 1 \ | ||
--dark-mode 0 \ | ||
--scale 1 \ | ||
--format png \ | ||
-o "./examples/simple_example_output.png" | ||
|
||
ls "./examples/simple_example_output.png" | ||
|
||
# SNIPPET_END | ||
: ECHO_SNIPPET_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{%- if True -%} | ||
#!/bin/bash | ||
# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425 | ||
set -e -x -v -u -o pipefail | ||
set +v | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # No Color | ||
PS4="${GREEN}$ ${NC}" | ||
|
||
EXCALIDRAW_BRUTE_EXPORT_CLI_URL=${EXCALIDRAW_BRUTE_EXPORT_CLI_URL:-} | ||
if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL}" ]]; then | ||
echo -e "${RED}EXCALIDRAW_BRUTE_EXPORT_CLI_URL is not set${NC}" | ||
exit 1 | ||
fi | ||
|
||
{% endif -%} | ||
|
||
{#- example_type: {docker-remote, docker-local, npm-module} -#} | ||
{#- docker_image_name: str -#} | ||
{#- module_name: str -#} | ||
{#- cmd: str -#} | ||
|
||
{%- macro abort(error) -%} | ||
{{ None['[ERROR] ' ~ error][0] }} | ||
{%- endmacro -%} | ||
|
||
{%- if example_type in ['docker-remote', 'docker-local'] -%} | ||
{% set cmd='docker run --rm --tty \\\n -u \"$(id -u):$(id -g)\" \\\n -v \"${PWD}:/data\" \\\n ' ~ docker_image_name %} | ||
{%- elif example_type=='npm-module' -%} | ||
{% set cmd='npx ' ~ module_name %} | ||
{%- else -%} | ||
{{ abort('example_type is unknown value: ' ~ example_type) }} | ||
{%- endif -%} | ||
|
||
{%- if example_type in ['docker-remote', 'docker-local'] %} | ||
|
||
# Don't run this in act/GH actions because act doesn't play with with nested | ||
# docker; the paths mess up. | ||
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then | ||
echo -e "${YELLOW}This script is not meant to be run in GitHub Actions.${NC}" | ||
exit 0 | ||
fi | ||
|
||
{% endif-%} | ||
|
||
: ECHO_SNIPPET_START | ||
# SNIPPET_START | ||
{% if example_type in ['docker-local'] -%} | ||
docker build -t {{docker_image_name|safe}} . | ||
|
||
{% endif -%} | ||
|
||
{% if example_type in ['docker-remote'] -%} | ||
# Use the published images at ghcr.io/realazthat/snipinator. | ||
{% endif -%} | ||
{% if example_type in ['docker-local', 'docker-remote'] -%} | ||
# /data in the docker image is the working directory, so paths are simpler. | ||
{% endif -%} | ||
{{cmd|safe}} \ | ||
-i ./examples/simple.excalidraw \ | ||
--background 1 \ | ||
--embed-scene 1 \ | ||
--dark-mode 0 \ | ||
--scale 1 \ | ||
--format png \ | ||
-o "./examples/simple_example_output.png" | ||
|
||
ls "./examples/simple_example_output.png" | ||
|
||
# SNIPPET_END | ||
: ECHO_SNIPPET_END |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425 | ||
set -e -x -v -u -o pipefail | ||
|
||
SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") | ||
source "${SCRIPT_DIR}/utilities/common.sh" | ||
|
||
################################################################################ | ||
PYTHON_VERSION_PATH=${PWD}/scripts/.python-version \ | ||
VENV_PATH=${PWD}/.cache/scripts/.venv \ | ||
source "${PROJ_PATH}/scripts/utilities/ensure-venv.sh" | ||
PYTHON_VERSION_PATH=${PWD}/scripts/.python-version \ | ||
TOML=${PROJ_PATH}/scripts/pyproject.toml EXTRA=dev \ | ||
DEV_VENV_PATH="${PWD}/.cache/scripts/.venv" \ | ||
TARGET_VENV_PATH="${PWD}/.cache/scripts/.venv" \ | ||
bash "${PROJ_PATH}/scripts/utilities/ensure-reqs.sh" | ||
################################################################################ | ||
|
||
|
||
CUSTOM_WARNING=$(cat << 'EOF' | ||
#!/bin/bash | ||
# WARNING: This file is auto-generated by snipinator. Do not edit directly. | ||
# SOURCE: `{template_file_name}`. | ||
. | ||
EOF | ||
) | ||
|
||
python -m snipinator.cli \ | ||
-t "${PROJ_PATH}/examples/simple_example.sh.jinja2" \ | ||
--args '{"example_type": "npm-module", "module_name": "excalidraw-brute-export-cli"}' \ | ||
--warning-header "${CUSTOM_WARNING%.}" \ | ||
--rm \ | ||
--force \ | ||
--create \ | ||
-o "${PROJ_PATH}/examples/simple_example.sh" \ | ||
--chmod-ro \ | ||
--skip-unchanged | ||
|
||
|
||
python -m snipinator.cli \ | ||
-t "${PROJ_PATH}/examples/simple_example.sh.jinja2" \ | ||
--args '{"example_type": "docker-local", "docker_image_name": "my-excalidraw-brute-export-cli-image"}' \ | ||
--warning-header "${CUSTOM_WARNING%.}" \ | ||
--rm \ | ||
--force \ | ||
--create \ | ||
-o "${PROJ_PATH}/examples/local-docker_example.sh" \ | ||
--chmod-ro \ | ||
--skip-unchanged | ||
|
||
|
||
LAST_VERSION=$(node -p "require('./package.json').version") | ||
python -m snipinator.cli \ | ||
-t "${PROJ_PATH}/examples/simple_example.sh.jinja2" \ | ||
--args '{"example_type": "docker-remote", "docker_image_name": "ghcr.io/realazthat/excalidraw-brute-export-cli:v'"${LAST_VERSION}"'"}' \ | ||
--warning-header "${CUSTOM_WARNING%.}" \ | ||
--rm \ | ||
--force \ | ||
--create \ | ||
-o "${PROJ_PATH}/examples/remote-docker_example-noautorun.sh" \ | ||
--chmod-ro \ | ||
--skip-unchanged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters