-
Notifications
You must be signed in to change notification settings - Fork 121
feat(jetbrains): add plugin pre-installation support #731
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
Open
Harsh9485
wants to merge
8
commits into
coder:main
Choose a base branch
from
Harsh9485:Pre-Install-jetBrains-Plugins-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+229
−1
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f553d3e
feat(jetbrains): add plugin pre-installation support
Harsh9485 8d94b75
Merge branch 'coder:main' into Pre-Install-jetBrains-Plugins-support
Harsh9485 2b22805
fix: terraform test file
Harsh9485 9063bd7
Merge branch 'Pre-Install-jetBrains-Plugins-support' of github.com:Ha…
Harsh9485 81db815
fix: sync all scripts execution order
Harsh9485 d1404b5
Merge branch 'main' into Pre-Install-jetBrains-Plugins-support
Harsh9485 e256d3e
fix: merge all coder_scripts
Harsh9485 ba62b0a
Merge branch 'main' into Pre-Install-jetBrains-Plugins-support
DevelopmentCats File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
118 changes: 118 additions & 0 deletions
118
registry/coder/modules/jetbrains/script/install_plugins.sh
This file contains hidden or 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,118 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| LOGFILE="$HOME/.config/jetbrains/install_plugins.log" | ||
| CONFIG_DIR="$HOME/.config/jetbrains" | ||
| IDE_CONFIG="$CONFIG_DIR/ide_config.json" | ||
| PLUGIN_MAP="$CONFIG_DIR/plugins.json" | ||
| IDE_BASE="$HOME/.local/share/JetBrains" | ||
|
|
||
| mkdir -p "$CONFIG_DIR" | ||
| exec > >(tee -a "$LOGFILE") 2>&1 | ||
|
|
||
| log() { | ||
| printf '%s %s\n' "$(date --iso-8601=seconds)" "$*" | ||
| } | ||
|
|
||
| # ---------- Read config ---------- | ||
| get_enabled_codes() { | ||
| jq -r 'keys[]' "$PLUGIN_MAP" | ||
| } | ||
|
|
||
| get_plugins_for_code() { | ||
| jq -r --arg CODE "$1" '.[$CODE][]?' "$PLUGIN_MAP" | ||
| } | ||
|
|
||
| get_build_for_code() { | ||
| jq -r --arg CODE "$1" '.[$CODE].build' "$IDE_CONFIG" | ||
| } | ||
|
|
||
| get_data_dir_for_code() { | ||
| local code="$1" | ||
| local build="$2" | ||
|
|
||
| local name | ||
| local build_prefix | ||
| local year | ||
| local minor | ||
|
|
||
| name="$(jq -r --arg CODE "$code" '.[$CODE].name' "$IDE_CONFIG")" | ||
|
|
||
| # build = 253.29346.142 → prefix = 253 | ||
| build_prefix="${build%%.*}" | ||
|
|
||
| # 253 → 2025.3 | ||
| year="20${build_prefix:0:2}" | ||
| minor="${build_prefix:2:1}" | ||
|
|
||
| printf '%s%s.%s\n' "$name" "$year" "$minor" | ||
| } | ||
|
|
||
| # ---------- Plugin installer ---------- | ||
| install_plugin() { | ||
| local code="$1" | ||
| local build="$2" | ||
| local dataDir="$3" | ||
| local pluginId="$4" | ||
|
|
||
| local plugins_dir="$IDE_BASE/$dataDir" | ||
| mkdir -p "$plugins_dir" | ||
|
|
||
| local url="https://plugins.jetbrains.com/pluginManager?action=download&id=$pluginId&build=$code-$build" | ||
|
|
||
| local workdir | ||
| workdir="$(mktemp -d)" | ||
| cd "$workdir" | ||
|
|
||
| log "Downloading $pluginId ($code-$build)" | ||
|
|
||
| if ! curl -fsSL -OJ "$url"; then | ||
| log "Download failed: $pluginId" | ||
| rm -rf "$workdir" | ||
| return 1 | ||
| fi | ||
|
|
||
| # We expect exactly one file after download | ||
| file="$(ls)" | ||
|
|
||
| # ---------- ZIP plugin ---------- | ||
| if unzip -t "$file" > /dev/null 2>&1; then | ||
| unzip -qq "$file" | ||
|
|
||
| entries=(*) | ||
| log "Extracted $file, found entries: ${entries[*]}" | ||
|
|
||
| if [ -d "${entries[0]}" ] && [ -d "${entries[0]}/lib" ]; then | ||
| cp -r "${entries[0]}" "$plugins_dir/" | ||
| log "Installed ZIP plugin $pluginId" | ||
| elif [[ "$file" == *.jar ]]; then | ||
| cp "$file" "$plugins_dir/" | ||
| log "Installed JAR plugin $pluginId" | ||
| fi | ||
| fi | ||
|
|
||
| cd / | ||
| rm -rf "$workdir" | ||
| } | ||
|
|
||
| # ---------- Main ---------- | ||
| log "Plugin installer started (build-based mode)" | ||
|
|
||
| [ ! -f "$PLUGIN_MAP" ] && log "No plugins.json found" && exit 0 | ||
| [ ! -f "$IDE_CONFIG" ] && log "No ide_config.json found" && exit 0 | ||
|
|
||
| get_enabled_codes | while read -r code; do | ||
| build="$(get_build_for_code "$code")" | ||
| dataDir="$(get_data_dir_for_code "$code" "$build")" | ||
|
|
||
| if [ -z "$build" ] || [ -z "$dataDir" ]; then | ||
| log "Missing config for $code, skipping" | ||
| continue | ||
| fi | ||
|
|
||
| get_plugins_for_code "$code" | while read -r plugin; do | ||
| [ -n "$plugin" ] && install_plugin "$code" "$build" "$dataDir" "$plugin" || continue | ||
| done | ||
| done | ||
|
|
||
| log "All plugins processed" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.