Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vscode devcontainer #1781

Merged
merged 7 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
kungfux marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Jekyll",
kungfux marked this conversation as resolved.
Show resolved Hide resolved
"image": "mcr.microsoft.com/devcontainers/jekyll:2-bullseye",
"onCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"postCreateCommand": "bash .devcontainer/post-create.sh",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
// Speed up extension installation
"extensions.verifySignature": false
kungfux marked this conversation as resolved.
Show resolved Hide resolved
},
"extensions": [
// Liquid tags auto-complete
"killalau.vscode-liquid-snippets",
// Liquid syntax highlighting and formatting
"Shopify.theme-check-vscode",
// Shell
"timonwong.shellcheck",
"mkhl.shfmt",
// Common formatter
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",
"yzhang.markdown-all-in-one",
// Git
"mhutchie.git-graph"
]
}
}
}
34 changes: 34 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

setup_node() {
bash -i -c "nvm install --lts && nvm install-latest-npm"

[[ -f package-lock.json && -d node_modules ]] || npm i
}

setup_assets() {
has_built_css=false
has_built_js=false

CSS_DIST="_sass/dist"
JS_DIST="assets/js/dist"

if [ -d "$CSS_DIST" ]; then
[ -z "$(ls -A $CSS_DIST)" ] || has_built_css=true
fi

if [ -d "$JS_DIST" ]; then
[ -z "$(ls -A $JS_DIST)" ] || has_built_js=true
fi

$has_built_css || npm run build:css
$has_built_js || npm run build:js
}

if [ -f package.json ]; then
setup_node
setup_assets
fi

# Install dependencies for shfmt extension
curl -sS https://webi.sh/shfmt | sh &>/dev/null
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ updates:
- "major"
schedule:
interval: "weekly"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package-lock.json

# IDE configurations
.idea
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json

Expand Down
12 changes: 1 addition & 11 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{
"recommendations": [
// Liquid tags auto-complete
"killalau.vscode-liquid-snippets",
// Liquid syntax highlighting and formatting
"Shopify.theme-check-vscode",
// Common formatter
"esbenp.prettier-vscode",
"foxundermoon.shell-format",
"stylelint.vscode-stylelint",
"yzhang.markdown-all-in-one"
]
"recommendations": ["ms-vscode-remote.remote-containers"]
}
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"editor.defaultFormatter": "Shopify.theme-check-vscode"
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
"editor.defaultFormatter": "mkhl.shfmt"
},
// Disable vscode built-in stylelint
"css.validate": false,
"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"]
}
6 changes: 6 additions & 0 deletions tools/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"