From 98d4375052306cb7dbda4ba5f3f5e60b5dc08dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:53:30 -0600 Subject: [PATCH] fix(templates): Ensure `.vscode` directory is included when requested in cookiecutters and avoid failing if it does not exist (#2183) fix(template): Ensure `.vscode` directory is included when requested in cookiecutters and do not fail if it does not exist --- .pre-commit-config.yaml | 4 ++++ cookiecutter/.gitignore | 2 ++ .../tap-template/hooks/post_gen_project.py | 2 +- .../.pre-commit-config.yaml | 6 +++++- .../.vscode/launch.json | 20 +++++++++++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 cookiecutter/.gitignore create mode 100644 cookiecutter/tap-template/{{cookiecutter.tap_id}}/.vscode/launch.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e466499a8..0501629fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,6 +8,10 @@ repos: rev: v4.5.0 hooks: - id: check-json + exclude: | + (?x)^( + .*/launch.json + )$ - id: check-toml exclude: | (?x)^( diff --git a/cookiecutter/.gitignore b/cookiecutter/.gitignore new file mode 100644 index 000000000..d6ea64289 --- /dev/null +++ b/cookiecutter/.gitignore @@ -0,0 +1,2 @@ +# Include template VSCode directory +!*/*/.vscode/ diff --git a/cookiecutter/tap-template/hooks/post_gen_project.py b/cookiecutter/tap-template/hooks/post_gen_project.py index ca51924f2..dc7134238 100644 --- a/cookiecutter/tap-template/hooks/post_gen_project.py +++ b/cookiecutter/tap-template/hooks/post_gen_project.py @@ -28,4 +28,4 @@ shutil.rmtree(".github") if "{{ cookiecutter.ide }}" != "VSCode": - shutil.rmtree(".vscode") + shutil.rmtree(".vscode", ignore_errors=True) diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.pre-commit-config.yaml b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.pre-commit-config.yaml index 5e3f6cb83..640e62aa2 100644 --- a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.pre-commit-config.yaml +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.pre-commit-config.yaml @@ -8,6 +8,10 @@ repos: rev: v4.5.0 hooks: - id: check-json + exclude: | + (?x)^( + \.vscode/.*\.json + )$ - id: check-toml - id: check-yaml - id: end-of-file-fixer @@ -20,7 +24,7 @@ repos: - id: check-github-workflows - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.11 + rev: v0.1.14 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix, --show-fixes] diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.vscode/launch.json b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.vscode/launch.json new file mode 100644 index 000000000..2605119c4 --- /dev/null +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "{{ cookiecutter.tap_id }}", + "type": "python", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": "{{ cookiecutter.library_name }}", + "justMyCode": false, + "args": [ + "--config", + ".secrets/config.json", + ], + }, + ] +}