From add1a53991c31f393e1f67e01d501d2102dd2a51 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sat, 1 Jun 2024 04:15:38 +0800 Subject: [PATCH] feat(dev): support vscode devcontainer --- .devcontainer/devcontainer.json | 20 ++++++++++++++++++++ .devcontainer/post-create.sh | 10 ++++++++++ .github/dependabot.yml | 4 ++++ .gitignore | 2 +- .vscode/extensions.json | 5 ++++- .vscode/settings.json | 4 ++-- tools/run.sh | 6 ++++++ 7 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/post-create.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..4fa88467101 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +{ + "name": "Jekyll", + "image": "mcr.microsoft.com/devcontainers/jekyll:2-bullseye", + "onCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}", + "postCreateCommand": "bash .devcontainer/post-create.sh", + "customizations": { + "vscode": { + "extensions": [ + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "foxundermoon.shell-format", + "killalau.vscode-liquid-snippets", + "mhutchie.git-graph", + "Shopify.theme-check-vscode", + "stylelint.vscode-stylelint", + "yzhang.markdown-all-in-one" + ] + } + } +} diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 00000000000..f53e186e50a --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +npm_buid() { + bash -i -c "nvm install --lts" + npm i && npm run build +} + +[[ -d _sass/dist && -d assets/js/dist ]] || npm_buid + +exec zsh diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 393fa980313..82bf3f7774c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -23,3 +23,7 @@ updates: - "major" schedule: interval: "weekly" + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/.gitignore b/.gitignore index d6bf5096400..e7803e6e697 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ package-lock.json # IDE configurations .idea -.vscode +.vscode/* !.vscode/settings.json !.vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 52bd6fbd046..f58eb468990 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,9 +5,12 @@ // Liquid syntax highlighting and formatting "Shopify.theme-check-vscode", // Common formatter + "EditorConfig.EditorConfig", "esbenp.prettier-vscode", "foxundermoon.shell-format", "stylelint.vscode-stylelint", - "yzhang.markdown-all-in-one" + "yzhang.markdown-all-in-one", + // DevContainer + "ms-vscode-remote.remote-containers" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index b0e2e099dc0..465f3615cb0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,6 +22,6 @@ "scss.validate": false, "less.validate": false, // Stylint extension settings - "stylelint.snippet": ["css", "less", "postcss", "scss"], - "stylelint.validate": ["css", "less", "postcss", "scss"] + "stylelint.snippet": ["css", "scss"], + "stylelint.validate": ["css", "scss"] } diff --git a/tools/run.sh b/tools/run.sh index 04f23f5e76b..3cb32901d04 100755 --- a/tools/run.sh +++ b/tools/run.sh @@ -46,5 +46,11 @@ if $prod; then command="JEKYLL_ENV=production $command" fi +if [ -e /proc/1/cgroup ]; then + if grep -q docker /proc/1/cgroup; then + command="$command --force_polling" + fi +fi + echo -e "\n> $command\n" eval "$command"