diff --git a/.gitattributes b/.gitattributes
index 6ada519..8c565d0 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,3 @@
* text=auto eol=lf
-*.* linguist-detectable=false
-/src/* linguist-detectable=true
+* linguist-detectable=false
+/src/** linguist-detectable=true
diff --git a/.github/README.example.terminal.svg b/.github/README.example.terminal.svg
deleted file mode 100644
index 56f56bd..0000000
--- a/.github/README.example.terminal.svg
+++ /dev/null
@@ -1,336 +0,0 @@
-
-
\ No newline at end of file
diff --git a/.github/README.help.generated.svg b/.github/README.help.generated.svg
index 5815f68..8d9c027 100644
--- a/.github/README.help.generated.svg
+++ b/.github/README.help.generated.svg
@@ -19,545 +19,545 @@ url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bo
font-style: bold;
font-weight: 700;
}
-.terminal-1435490868-matrix {
+.terminal-4099070515-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
-.terminal-1435490868-title {
+.terminal-4099070515-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
-.terminal-1435490868-r1 { fill: #d9d9d9 }
-.terminal-1435490868-r2 { fill: #878787 }
-.terminal-1435490868-r3 { fill: #d9d9d9;font-weight: bold }
-.terminal-1435490868-r4 { fill: #569cd6 }
-.terminal-1435490868-r5 { fill: #98e024 }
-.terminal-1435490868-r6 { fill: #aaaaaa }
-.terminal-1435490868-r7 { fill: #608b1a }
+.terminal-4099070515-r1 { fill: #d9d9d9 }
+.terminal-4099070515-r2 { fill: #878787 }
+.terminal-4099070515-r3 { fill: #d9d9d9;font-weight: bold }
+.terminal-4099070515-r4 { fill: #569cd6 }
+.terminal-4099070515-r5 { fill: #98e024 }
+.terminal-4099070515-r6 { fill: #aaaaaa }
+.terminal-4099070515-r7 { fill: #608b1a }
+ + ✅Requirements + • + 🐳Docker + • 🚸Gotchas
@@ -119,33 +126,27 @@ npx playwright install firefox Example: -{% set example_cmd=' -npx excalidraw-brute-export-cli \\ - -i ./examples/simple.excalidraw \\ - --background 1 \\ - --embed-scene 0 \\ - --dark-mode 0 \\ - --scale 1 \\ - --format svg \\ - -o "./README.example.output.svg" -' | trim %} - -```bash -# Use this command: -{{ example_cmd | safe }} -``` - - + + + And the resulting image (svg): - + ## 💻 Command Line Options @@ -223,6 +224,26 @@ npx excalidraw-brute-export-cli \ - WSL2 Ubuntu 20.04, Node `{{rawsnippet('./.nvmrc')|trim}}` using Excalidraw at tag `{{rawsnippet('./.github/.excalidraw-tag')|trim}}`. +## 🐳 Docker Image + +Docker images are published to [ghcr.io/realazthat/{{project_name}}][49] at each +tag. + + + +If you want to build the image yourself, you can use the Dockerfile in the +repository. + + + ## 🚸 Gotchas and Limitations - Sometimes playwright times out. diff --git a/.github/README.remotified.md b/.github/README.remotified.md index c60b4be..9bafb3b 100644 --- a/.github/README.remotified.md +++ b/.github/README.remotified.md @@ -29,8 +29,15 @@ SOURCE: `.github/README.md.jinja2`. 🎇Features • 🏠Installation • 🚜Usage • - 💻CLI • - ✅Requirements • + 💻CLI + + ++ + ✅Requirements + • + 🐳Docker + • 🚸Gotchas
@@ -57,7 +64,7 @@ exact same export process as Excalidraw itself** - + - ❔ What: Uses [🎭 playwright][2] to run a headless firefox browser to export [Excalidraw][3] diagrams to svg/png files. Using a browser bypasses certain @@ -111,7 +118,7 @@ exact same export process as Excalidraw itself** npm install -g excalidraw-brute-export-cli # Or install globally, direct from GitHub: -npm install -g https://github.com/realazthat/excalidraw-brute-export-cli.git#v0.3.2 +npm install -g https://github.com/realazthat/excalidraw-brute-export-cli.git#v0.4.0 # Might prompt for root. npx playwright install-deps @@ -122,10 +129,9 @@ npx playwright install firefox Example: - - + ```bash -# Use this command: + npx excalidraw-brute-export-cli \ -i ./examples/simple.excalidraw \ --background 1 \ @@ -133,18 +139,24 @@ npx excalidraw-brute-export-cli \ --dark-mode 0 \ --scale 1 \ --format svg \ - -o "./README.example.output.svg" + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + ``` + - + + + And the resulting image (svg): - + ## 💻 Command Line Options - + ## 🐳 Running Excalidraw locally @@ -203,7 +215,7 @@ npx excalidraw-brute-export-cli \ Excalidraw tag `v0.15.0` for more consistent output, and testing. - Supported Node versions: `>=18.0.0 <19.0.0 || >=20.0.0 <21.0.0 || >=21.0.0 <22.0.0 || >=22.0.0 <23.0.0` (See - [./package.json](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/package.json)). These versions were chosen from + [./package.json](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/package.json)). These versions were chosen from current supported and upcoming versions of node, from [Node.js: Previous Releases](https://nodejs.org/en/about/previous-releases). - Tested Node versions on GitHub Actions: `["18.20.2","20.12.1","21.7.3","22.0.0"]`. @@ -213,6 +225,59 @@ npx excalidraw-brute-export-cli \ - WSL2 Ubuntu 20.04, Node `v20.12.1` using Excalidraw at tag `v0.15.0`. +## 🐳 Docker Image + +Docker images are published to [ghcr.io/realazthat/excalidraw-brute-export-cli][49] at each +tag. + + +```bash + +# 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.4.0 \ + -i ./examples/simple.excalidraw \ + --background 1 \ + --embed-scene 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +``` + + +If you want to build the image yourself, you can use the Dockerfile in the +repository. + + +```bash + +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 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +``` + + ## 🚸 Gotchas and Limitations - Sometimes playwright times out. @@ -231,7 +296,7 @@ repository. ## 🔑 License This project is licensed under the MIT License - see the -[./LICENSE.md](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/LICENSE.md) file for details. +[./LICENSE.md](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/LICENSE.md) file for details. ## 🫡 Contributions @@ -239,7 +304,7 @@ This project is licensed under the MIT License - see the - For running `pre.sh` (Linux-like environment). - - From [./.github/dependencies.yml](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/.github/dependencies.yml), which is used for + - From [./.github/dependencies.yml](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/.github/dependencies.yml), which is used for the GH Action to do a fresh install of everything: ```yaml @@ -258,13 +323,13 @@ This project is licensed under the MIT License - see the ``` - Requires `pyenv`, or an exact matching version of python as in - [scripts/.python-version](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/scripts/.python-version) (which is currently + [scripts/.python-version](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/scripts/.python-version) (which is currently `3.8.18 `). - `jq`, ([installation](https://jqlang.github.io/jq/)) required for [yq](https://github.com/kislyuk/yq), which is itself required for our - [./README.md](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/README.md) generation, which uses `tomlq` (from the + [./README.md](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/README.md) generation, which uses `tomlq` (from the [yq](https://github.com/kislyuk/yq) package) to include version strings from - [./scripts/pyproject.toml](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/scripts/pyproject.toml). + [./scripts/pyproject.toml](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/scripts/pyproject.toml). - act (to run the GH Action locally): - Requires nodejs. - Requires Go. @@ -277,16 +342,16 @@ This project is licensed under the MIT License - see the ### Commit Process 1. (Optionally) Fork the `develop` branch. -2. If the [.github/demo.gif](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/.github/demo.gif) will change, run +2. If the [.github/demo.gif](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/.github/demo.gif) will change, run `bash ./scripts/generate-animation.sh`, this will generate a new - [.github/demo.gif](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/.github/demo.gif). + [.github/demo.gif](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/.github/demo.gif). - Sanity-check the animation visually! - Unfortunately, every run will make a unique gif, please don't stage this file unless it changes due to some feature change or somesuch. 3. Stage your files: e.g `git add path/to/file.py`. 4. `bash ./scripts/pre.sh`, this will format, lint, and test the code. 5. `git status` check if anything changed (generated - [README.md](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/README.md) for example), if so, `git add` the changes, + [README.md](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/README.md) for example), if so, `git add` the changes, and go back to the previous step. 6. `git commit -m "..."`. 7. Make a PR to `develop` (or push to develop if you have the rights). @@ -298,7 +363,7 @@ These instructions are for maintainers of the project. 1. In the `develop` branch, run `bash ./scripts/pre.sh` to ensure everything is in order. 2. In the `develop` branch, bump the version in - [package.json](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/package.json), following semantic versioning + [package.json](https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/package.json), following semantic versioning principles. Run `bash ./scripts/pre.sh` to ensure everything is in order. - If anything got generated (e.g README or terminal output images), you will have to stage those. @@ -318,7 +383,7 @@ These instructions are for maintainers of the project. `git checkout develop && git merge master`. 9. Push the develop branch to GitHub: `git push origin develop`. -[1]: https://raw.githubusercontent.com/realazthat/excalidraw-brute-export-cli/v0.3.2/.github/logo-exported.svg +[1]: https://raw.githubusercontent.com/realazthat/excalidraw-brute-export-cli/v0.4.0/.github/logo-exported.svg [2]: https://playwright.dev/ [3]: https://excalidraw.com/ @@ -331,7 +396,7 @@ These instructions are for maintainers of the project. [5]: https://img.shields.io/badge/Platform-Node-0A1E1E?style=plastic&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWxhcHRvcC1taW5pbWFsIj48cmVjdCB3aWR0aD0iMTgiIGhlaWdodD0iMTIiIHg9IjMiIHk9IjQiIHJ4PSIyIiByeT0iMiIvPjxsaW5lIHgxPSIyIiB4Mj0iMjIiIHkxPSIyMCIgeTI9IjIwIi8+PC9zdmc+ [6]: https://img.shields.io/github/languages/top/realazthat/excalidraw-brute-export-cli.svg?&cacheSeconds=28800&style=plastic&color=0A1E1E [7]: https://img.shields.io/github/license/realazthat/excalidraw-brute-export-cli?style=plastic&color=0A1E1E -[8]: https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.3.2/LICENSE.md +[8]: https://github.com/realazthat/excalidraw-brute-export-cli/blob/v0.4.0/LICENSE.md [9]: https://img.shields.io/npm/v/excalidraw-brute-export-cli?style=plastic&color=0A1E1E [10]: https://www.npmjs.com/package/excalidraw-brute-export-cli [11]: https://github.com/realazthat/excalidraw-brute-export-cli/tree/master @@ -339,12 +404,12 @@ These instructions are for maintainers of the project. [13]: https://img.shields.io/github/actions/workflow/status/realazthat/excalidraw-brute-export-cli/build-and-test.yml?branch=master&style=plastic [14]: https://img.shields.io/github/actions/workflow/status/realazthat/excalidraw-brute-export-cli/build-and-test.yml?branch=develop&style=plastic [15]: https://github.com/realazthat/excalidraw-brute-export-cli/actions/workflows/build-and-test.yml -[16]: https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.3.2/master?style=plastic -[17]: https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.3.2/develop?style=plastic -[18]: https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.3.2...master -[19]: https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.3.2...develop -[20]: https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.3.2/develop?style=plastic -[21]: https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.3.2...develop +[16]: https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.4.0/master?style=plastic +[17]: https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.4.0/develop?style=plastic +[18]: https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.4.0...master +[19]: https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.4.0...develop +[20]: https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.4.0/develop?style=plastic +[21]: https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.4.0...develop [22]: https://img.shields.io/github/last-commit/realazthat/excalidraw-brute-export-cli/master?style=plastic [23]: https://img.shields.io/github/last-commit/realazthat/excalidraw-brute-export-cli/develop?style=plastic [24]: https://img.shields.io/node/v/excalidraw-brute-export-cli?style=plastic&color=0A1E1E diff --git a/.github/README.simple_example.log.svg b/.github/README.simple_example.log.svg new file mode 100644 index 0000000..f7c05e4 --- /dev/null +++ b/.github/README.simple_example.log.svg @@ -0,0 +1,367 @@ + + \ No newline at end of file diff --git a/.github/simple_example.log b/.github/simple_example.log new file mode 100644 index 0000000..7c950e8 --- /dev/null +++ b/.github/simple_example.log @@ -0,0 +1,53 @@ +[0;32m$ [0mset -e -x -v -u -o pipefail +set +v +[0;32m$ [0mset +v +[0;32m$ [0mGREEN='\033[0;32m' +[0;32m$ [0mYELLOW='\033[1;33m' +[0;32m$ [0mNC='\033[0m' +[0;32m$ [0mPS4='\033[0;32m$ \033[0m' +[0;32m$ [0mEXCALIDRAW_BRUTE_EXPORT_CLI_URL=http://localhost:59876 +[0;32m$ [0m[[ -z http://localhost:59876 ]] +[0;32m$ [0m: ECHO_SNIPPET_START +[0;32m$ [0mnpx excalidraw-brute-export-cli -i ./examples/simple.excalidraw --background 1 --embed-scene 0 --dark-mode 0 --scale 1 --format svg -o ./examples/simple_example_output.svg +[38;2;86;156;214minfo[39m: options: +[38;2;86;156;214minfo[39m: { + i: [32m'./examples/simple.excalidraw'[39m, + input: [32m'./examples/simple.excalidraw'[39m, + background: [33mtrue[39m, + b: [33mtrue[39m, + embedScene: [33mfalse[39m, + e: [33mfalse[39m, + darkMode: [33mfalse[39m, + d: [33mfalse[39m, + scale: [33m1[39m, + s: [33m1[39m, + format: [32m'svg'[39m, + f: [32m'svg'[39m, + o: [32m'./examples/simple_example_output.svg'[39m, + output: [32m'./examples/simple_example_output.svg'[39m, + url: [32m''[39m, + excalidrawVersion: [32m''[39m, + headless: [33mtrue[39m, + leaveBrowserRunning: [33mfalse[39m, + screenshots: [32m''[39m, + actionSleepTime: [33m200[39m, + timeout: [33m-1[39m +} +[38;2;86;156;214minfo[39m: Falling back to environment variable EXCALIDRAW_BRUTE_EXPORT_CLI_URL +[38;2;86;156;214minfo[39m: excalidrawURL: http://localhost:59876 +[38;2;86;156;214minfo[39m: Detecting Excalidraw version... +[38;2;86;156;214minfo[39m: excalidrawVersion: 0.15.0 +[38;2;86;156;214minfo[39m: Clicking: Menu Burger +[38;2;86;156;214minfo[39m: Clicking: Open Menu Item +[38;2;86;156;214minfo[39m: File is chosen! +[38;2;86;156;214minfo[39m: Clicking: Export Menu Item +[38;2;86;156;214minfo[39m: await exportBackgroundSwitch.count(): 1 +[38;2;86;156;214minfo[39m: await exportEmbedSwitch.count(): 1 +[38;2;86;156;214minfo[39m: await exportScaleDiv.count(): 1 +[38;2;86;156;214minfo[39m: await exportScaleElements.count(): 3 +[38;2;86;156;214minfo[39m: Pressing SVG button! +[38;2;86;156;214minfo[39m: File is downloaded! +[38;2;86;156;214minfo[39m: closing... +[0;32m$ [0mls ./examples/simple_example_output.svg +./examples/simple_example_output.svg +[0;32m$ [0m: ECHO_SNIPPET_END diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b62fee6..7313495 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: detect-private-key - id: double-quote-string-fixer - id: end-of-file-fixer - exclude: ^.*\.(md|svg)$ + exclude: ^.*\.(md|svg|sh)$ - id: fix-byte-order-marker - id: mixed-line-ending - id: name-tests-test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3bbdbed --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM node:20.12.1-bullseye-slim + + +WORKDIR /excalidraw-brute-export-cli + +RUN apt-get -y update && apt-get -y --no-install-recommends install bash && \ + apt-get -y clean && \ + apt-get -y autoremove && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir -p /excalidraw-brute-export-cli && \ + chmod -R a+wrX /excalidraw-brute-export-cli && \ + chown -R node:node /excalidraw-brute-export-cli && \ + npx --yes playwright install-deps + + +COPY --chown=node:node . /excalidraw-brute-export-cli + +USER node +# ENV NPM_CONFIG_PREFIX=/home/node/.npm-global +# ENV PATH=/home/node/.npm-global/bin:$PATH +WORKDIR /excalidraw-brute-export-cli +RUN npm install . && npx playwright install + +# This is where the user will mount their data to. +WORKDIR /data + +ENTRYPOINT ["npx", "--prefix", "/excalidraw-brute-export-cli", "excalidraw-brute-export-cli"] +CMD ["--help"] +HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ + CMD npx excalidraw-brute-export-cli --version || exit 1 diff --git a/README.md b/README.md index d3c9a0c..c5e337f 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,15 @@ SOURCE: `.github/README.md.jinja2`. 🎇Features • 🏠Installation • 🚜Usage • - 💻CLI • - ✅Requirements • + 💻CLI + + ++ + ✅Requirements + • + 🐳Docker + • 🚸Gotchas
@@ -111,7 +118,7 @@ exact same export process as Excalidraw itself** npm install -g excalidraw-brute-export-cli # Or install globally, direct from GitHub: -npm install -g https://github.com/realazthat/excalidraw-brute-export-cli.git#v0.3.2 +npm install -g https://github.com/realazthat/excalidraw-brute-export-cli.git#v0.4.0 # Might prompt for root. npx playwright install-deps @@ -122,10 +129,9 @@ npx playwright install firefox Example: - - + ```bash -# Use this command: + npx excalidraw-brute-export-cli \ -i ./examples/simple.excalidraw \ --background 1 \ @@ -133,14 +139,20 @@ npx excalidraw-brute-export-cli \ --dark-mode 0 \ --scale 1 \ --format svg \ - -o "./README.example.output.svg" + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + ``` + - + + + And the resulting image (svg): - + ## 💻 Command Line Options @@ -213,6 +225,59 @@ npx excalidraw-brute-export-cli \ - WSL2 Ubuntu 20.04, Node `v20.12.1` using Excalidraw at tag `v0.15.0`. +## 🐳 Docker Image + +Docker images are published to [ghcr.io/realazthat/excalidraw-brute-export-cli][49] at each +tag. + + +```bash + +# 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.4.0 \ + -i ./examples/simple.excalidraw \ + --background 1 \ + --embed-scene 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +``` + + +If you want to build the image yourself, you can use the Dockerfile in the +repository. + + +```bash + +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 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +``` + + ## 🚸 Gotchas and Limitations - Sometimes playwright times out. @@ -349,17 +414,17 @@ These instructions are for maintainers of the project. [15]: https://github.com/realazthat/excalidraw-brute-export-cli/actions/workflows/build-and-test.yml [16]: - https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.3.2/master?style=plastic + https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.4.0/master?style=plastic [17]: - https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.3.2/develop?style=plastic + https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.4.0/develop?style=plastic [18]: - https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.3.2...master + https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.4.0...master [19]: - https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.3.2...develop + https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.4.0...develop [20]: - https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.3.2/develop?style=plastic + https://img.shields.io/github/commits-since/realazthat/excalidraw-brute-export-cli/v0.4.0/develop?style=plastic [21]: - https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.3.2...develop + https://github.com/realazthat/excalidraw-brute-export-cli/compare/v0.4.0...develop [22]: https://img.shields.io/github/last-commit/realazthat/excalidraw-brute-export-cli/master?style=plastic [23]: diff --git a/examples/simple-local-docker_example.sh b/examples/simple-local-docker_example.sh new file mode 100755 index 0000000..9219fa8 --- /dev/null +++ b/examples/simple-local-docker_example.sh @@ -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 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +# SNIPPET_END +: ECHO_SNIPPET_END diff --git a/examples/simple-remote-docker_example-noautorun.sh b/examples/simple-remote-docker_example-noautorun.sh new file mode 100644 index 0000000..254b418 --- /dev/null +++ b/examples/simple-remote-docker_example-noautorun.sh @@ -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.4.0 \ + -i ./examples/simple.excalidraw \ + --background 1 \ + --embed-scene 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +# SNIPPET_END +: ECHO_SNIPPET_END diff --git a/examples/simple.sh b/examples/simple.sh deleted file mode 100755 index 3af1f80..0000000 --- a/examples/simple.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425 -set -e -x -v -u -o pipefail - -mkdir -p "./.deleteme" -rm "./.deleteme/output.png" || true -npx excalidraw-brute-export-cli \ - -i ./examples/simple.excalidraw \ - --background 1 \ - --embed-scene 1 \ - --dark-mode 0 \ - --scale 1 \ - --format png \ - -o "./.deleteme/output.png" - -ls "./.deleteme/output.png" diff --git a/examples/simple_example.sh b/examples/simple_example.sh new file mode 100755 index 0000000..4b877ad --- /dev/null +++ b/examples/simple_example.sh @@ -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 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +# SNIPPET_END +: ECHO_SNIPPET_END diff --git a/examples/simple_example.sh.jinja2 b/examples/simple_example.sh.jinja2 new file mode 100644 index 0000000..823ed2b --- /dev/null +++ b/examples/simple_example.sh.jinja2 @@ -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 0 \ + --dark-mode 0 \ + --scale 1 \ + --format svg \ + -o "./examples/simple_example_output.svg" + +ls "./examples/simple_example_output.svg" + +# SNIPPET_END +: ECHO_SNIPPET_END diff --git a/examples/simple_example_output.svg b/examples/simple_example_output.svg new file mode 100644 index 0000000..52d7eec --- /dev/null +++ b/examples/simple_example_output.svg @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/lib/version.js b/lib/version.js index 76905bc..5e7afbb 100644 --- a/lib/version.js +++ b/lib/version.js @@ -1,2 +1,2 @@ // Generated by genversion. -export const version = '0.3.2' +export const version = '0.4.0' diff --git a/package-lock.json b/package-lock.json index e9f58aa..39d60a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "excalidraw-brute-export-cli", - "version": "0.3.2", + "version": "0.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "excalidraw-brute-export-cli", - "version": "0.3.2", + "version": "0.4.0", "dependencies": { "@caporal/core": "^2.0.7", "playwright": "^1.43.0" diff --git a/package.json b/package.json index 9eef833..e2b23dd 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,11 @@ "excalidraw-brute-export-cli": "./src/main.js" }, "type": "module", - "version": "0.3.2", + "version": "0.4.0", "scripts": { "format": "npx prettier --write package.json && npx prettier --write src/ && npx prettier --write --parser markdown \"LICENSE.md\" \".github/README.md.jinja2\" --write", "genversion": "genversion --esm lib/version.js", - "prepublishOnly": "git diff --cached --name-only | xargs npm pack --dry-run" + "prepublishOnly": "cp -f .github/README.remotified.md README.md && git diff --cached --name-only | xargs npm pack --dry-run" }, "dependencies": { "@caporal/core": "^2.0.7", diff --git a/scripts/format.sh b/scripts/format.sh index 6af5258..4a8ead3 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -2,4 +2,4 @@ # https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425 set -e -x -v -u -o pipefail -npm run format +npm install && npm run format diff --git a/scripts/generate-examples.sh b/scripts/generate-examples.sh new file mode 100755 index 0000000..afc6062 --- /dev/null +++ b/scripts/generate-examples.sh @@ -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/simple-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/simple-remote-docker_example-noautorun.sh" \ + --chmod-ro \ + --skip-unchanged \ No newline at end of file diff --git a/scripts/generate-readme.sh b/scripts/generate-readme.sh index 2ff4a40..a270972 100755 --- a/scripts/generate-readme.sh +++ b/scripts/generate-readme.sh @@ -12,7 +12,6 @@ if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL}" ]]; then echo -e "${RED}EXCALIDRAW_BRUTE_EXPORT_CLI_URL is not set${NC}" exit 1 fi -export EXCALIDRAW_BRUTE_EXPORT_CLI_URL ################################################################################ PYTHON_VERSION_PATH=${PWD}/scripts/.python-version \ VENV_PATH=${PWD}/.cache/scripts/.venv \ @@ -29,6 +28,7 @@ NODE_VERSION_PATH=${PWD}/.nvmrc \ bash scripts/format.sh +( # FORCE_COLOR and TERM are set, to produce consistent results across different # systems. # @@ -56,10 +56,19 @@ export TERM=dumb export CLI_WIDTH=120 export LINES=40 export COLUMNS=120 + + +# Try to make terminal output as consistent as possible. +FORCE_COLOR=3 TERM=dumb CLI_WIDTH=120 COLUMNS=120 LINES=40 \ +PS4="${GREEN}$ ${NC}" unbuffer bash -x ./examples/simple_example.sh \ + > .github/simple_example.log 2>&1 + + python -m snipinator.cli \ -t "${PROJ_PATH}/.github/README.md.jinja2" \ -o "${PROJ_PATH}/README.md" \ - --rm --force --create --chmod-ro + --rm --force --create --chmod-ro --skip-unchanged +) ################################################################################ LAST_VERSION=$(node -p "require('./package.json').version") python -m mdremotifier.cli \ diff --git a/scripts/generate.sh b/scripts/generate.sh index a02992c..efb1125 100755 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -16,7 +16,15 @@ PYTHON_VERSION_PATH=${PWD}/scripts/.python-version \ bash "${PROJ_PATH}/scripts/utilities/ensure-reqs.sh" ################################################################################ +npm install +if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL:-}" ]]; then + source scripts/run-excalidraw.sh +fi + + +npm run genversion bash scripts/format.sh +bash scripts/generate-examples.sh bash scripts/run-all-examples.sh bash scripts/generate-readme.sh ################################################################################ diff --git a/scripts/pre.sh b/scripts/pre.sh index 36a4fbc..e27140d 100755 --- a/scripts/pre.sh +++ b/scripts/pre.sh @@ -18,8 +18,6 @@ IDEAL="0" if [[ "${WANTED_NODE_VERSION}" == "${IDEAL_NODE_VERSION}" && "${EXCALIDRAW_TAG}" == "${IDEAL_EXCALIDRAW_TAG}" ]]; then IDEAL="1" - export EXCALIDRAW_PORT=59876 - export EXCALIDRAW_INSTANCE_NAME="test-excalidraw" fi if [[ -z "${GITHUB_ACTIONS:-}" ]]; then @@ -45,10 +43,8 @@ npm install EXTRA=dev bash scripts/utilities/pin-extra-reqs.sh npm run genversion -source scripts/run-excalidraw.sh -if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL}" ]]; then - echo -e "${RED}EXCALIDRAW_BRUTE_EXPORT_CLI_URL is not set${NC}" - exit 1 +if [[ -z "${EXCALIDRAW_BRUTE_EXPORT_CLI_URL:-}" ]]; then + source scripts/run-excalidraw.sh fi bash scripts/generate.sh diff --git a/scripts/run-all-examples.sh b/scripts/run-all-examples.sh index 5112698..42913d0 100755 --- a/scripts/run-all-examples.sh +++ b/scripts/run-all-examples.sh @@ -19,12 +19,33 @@ NODE_VERSION_PATH=${PWD}/.nvmrc \ # FORCE_COLOR and TERM are set, to produce consistent results across different # systems. # -# See generate-readme.sh for explanation. +# Explanation: +# +# @caporal/core is used for argument parsing. +# +# chalk/chalk, via @caporal/core, uses an internal copy of the supports-color +# library (https://github.com/chalk/supports-color) here: +#