-
Notifications
You must be signed in to change notification settings - Fork 65
#1866 implement claude url updater #1871
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
AdemZarrouki
wants to merge
10
commits into
devonfw:main
Choose a base branch
from
AdemZarrouki:feature/1866-claude-url-updater
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.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
347128d
#1866: Add ClaudeUrlUpdater for Claude Code CLI
AdemZarrouki 455cc80
#1866: Add mock and tests for ClaudeUrlUpdater using WireMock
AdemZarrouki 2f44206
#1866: Add ClaudeUrlUpdater to UpdateManager
AdemZarrouki 591de4c
#1685: Add CPE vendor and product methods to CopilotUrlUpdater
AdemZarrouki 51a2102
Revert "#1685: Add CPE vendor and product methods to CopilotUrlUpdater"
AdemZarrouki d76b081
#1866: Add CPE vendor and product methods to ClaudeUrlUpdater
AdemZarrouki 803146b
#1866: Fix documentation URL in ClaudeUrlUpdater
AdemZarrouki 6788430
#1866: Update minimum Claude version identifier to 2.1.118 in ClaudeU…
AdemZarrouki ead1038
#1866: Update Claude version references to 2.1.119 in claude-tags.jso…
AdemZarrouki d2d9bc2
#1866: exclude version 2.1.120 from claude and adapt MIN_CLAUDE_VID t…
AdemZarrouki 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
67 changes: 67 additions & 0 deletions
67
url-updater/src/main/java/com/devonfw/tools/ide/url/tool/claude/ClaudeUrlUpdater.java
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,67 @@ | ||
| package com.devonfw.tools.ide.url.tool.claude; | ||
|
|
||
| import com.devonfw.tools.ide.url.model.folder.UrlVersion; | ||
| import com.devonfw.tools.ide.url.updater.GithubUrlTagUpdater; | ||
| import com.devonfw.tools.ide.version.VersionIdentifier; | ||
|
|
||
| /** | ||
| * {@link GithubUrlTagUpdater} for GitHub Claude Code CLI. | ||
| * <p> | ||
| * Follows the official installation structure from GitHub's claude-code repository: https://github.com/anthropics/claude-code. | ||
| * <p> | ||
| * Download URL pattern: https://github.com/anthropics/claude-code/releases/download/v${VERSION}/claude-${PLATFORM}-${ARCH}.tar.gz | ||
| */ | ||
| public class ClaudeUrlUpdater extends GithubUrlTagUpdater { | ||
|
|
||
| private static final VersionIdentifier MIN_CLAUDE_VID = VersionIdentifier.of("2.1.117"); | ||
| private static final VersionIdentifier EXCLUDED_VERSION = VersionIdentifier.of("2.1.120"); | ||
|
|
||
|
|
||
| @Override | ||
| public String getTool() { | ||
| return "claude"; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getGithubOrganization() { | ||
| return "anthropics"; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getGithubRepository() { | ||
| return "claude-code"; | ||
| } | ||
|
|
||
| @Override | ||
| protected void addVersion(UrlVersion urlVersion) { | ||
| String baseUrl = createGithubReleaseDownloadUrl("v${version}", "claude-"); | ||
| VersionIdentifier vid = urlVersion.getVersionIdentifier(); | ||
|
|
||
| if (vid.compareVersion(MIN_CLAUDE_VID).isGreater() && !vid.compareVersion(EXCLUDED_VERSION).isEqual()) { | ||
|
|
||
|
AdemZarrouki marked this conversation as resolved.
|
||
| doAddVersion(urlVersion, baseUrl + "linux-x64.tar.gz", LINUX, X64); | ||
| doAddVersion(urlVersion, baseUrl + "linux-arm64.tar.gz", LINUX, ARM64); | ||
|
|
||
| doAddVersion(urlVersion, baseUrl + "darwin-x64.tar.gz", MAC, X64); | ||
| doAddVersion(urlVersion, baseUrl + "darwin-arm64.tar.gz", MAC, ARM64); | ||
|
|
||
| doAddVersion(urlVersion, baseUrl + "win32-x64.zip", WINDOWS, X64); | ||
| doAddVersion(urlVersion, baseUrl + "win32-arm64.zip", WINDOWS, ARM64); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected String getVersionPrefixToRemove() { | ||
| return "v"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getCpeVendor() { | ||
| return "claude-code"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getCpeProduct() { | ||
| return "claude-code"; | ||
| } | ||
| } | ||
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
31 changes: 31 additions & 0 deletions
31
url-updater/src/test/java/com/devonfw/tools/ide/url/tool/claude/ClaudeUrlUpdaterMock.java
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,31 @@ | ||
| package com.devonfw.tools.ide.url.tool.claude; | ||
|
|
||
| import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; | ||
|
|
||
| /** | ||
| * Mock of {@link ClaudeUrlUpdater} to allow integration testing with wiremock. | ||
| */ | ||
| public class ClaudeUrlUpdaterMock extends ClaudeUrlUpdater { | ||
|
|
||
| private final String baseUrl; | ||
|
|
||
| private final WireMockRuntimeInfo wmRuntimeInfo; | ||
|
|
||
| ClaudeUrlUpdaterMock(WireMockRuntimeInfo wireMockRuntimeInfo) { | ||
| super(); | ||
| this.wmRuntimeInfo = wireMockRuntimeInfo; | ||
| this.baseUrl = wireMockRuntimeInfo.getHttpBaseUrl(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getDownloadBaseUrl() { | ||
| return this.baseUrl; | ||
| } | ||
|
|
||
| @Override | ||
| protected String doGetVersionUrl() { | ||
| return this.baseUrl + "/repos/" + getGithubOrganization() + "/" + getGithubRepository() + "/git/refs/tags"; | ||
| } | ||
| } | ||
|
|
||
|
|
53 changes: 53 additions & 0 deletions
53
url-updater/src/test/java/com/devonfw/tools/ide/url/tool/claude/ClaudeUrlUpdaterTest.java
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,53 @@ | ||
| package com.devonfw.tools.ide.url.tool.claude; | ||
|
|
||
| import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.any; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Path; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import com.devonfw.tools.ide.url.model.folder.UrlRepository; | ||
| import com.devonfw.tools.ide.url.updater.AbstractUrlUpdaterTest; | ||
| import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; | ||
| import com.github.tomakehurst.wiremock.junit5.WireMockTest; | ||
|
|
||
| /** | ||
| * Test of {@link ClaudeUrlUpdater}. | ||
| */ | ||
| @WireMockTest | ||
| class ClaudeUrlUpdaterTest extends AbstractUrlUpdaterTest { | ||
|
|
||
| /** | ||
| * Test of {@link ClaudeUrlUpdater} for the creation of download URLs and checksums. | ||
| * | ||
| * @param tempDir Path to a temporary directory | ||
| * @param wmRuntimeInfo the {@link WireMockRuntimeInfo}. | ||
| * @throws IOException test fails | ||
| */ | ||
| @Test | ||
| void testClaudeUrlUpdater(@TempDir Path tempDir, WireMockRuntimeInfo wmRuntimeInfo) throws IOException { | ||
| // arrange | ||
| stubFor(get(urlMatching("/repos/anthropics/claude-code/git/refs/tags")).willReturn(aResponse().withStatus(200) | ||
| .withBody(readAndResolve(PATH_INTEGRATION_TEST.resolve("ClaudeUrlUpdater").resolve("claude-tags.json"), wmRuntimeInfo)))); | ||
|
|
||
| stubFor(any(urlMatching("/anthropics/claude-code/releases/download/.*")).willReturn(aResponse().withStatus(200).withBody(DOWNLOAD_CONTENT))); | ||
|
|
||
| UrlRepository urlRepository = UrlRepository.load(tempDir); | ||
| ClaudeUrlUpdaterMock updater = new ClaudeUrlUpdaterMock(wmRuntimeInfo); | ||
|
|
||
| // act | ||
| updater.update(urlRepository); | ||
|
|
||
| // assert | ||
| Path claudeDir = tempDir.resolve("claude").resolve("claude"); | ||
| assertUrlVersionOsX64(claudeDir.resolve("2.1.118")); | ||
| } | ||
| } | ||
|
|
||
|
|
9 changes: 9 additions & 0 deletions
9
url-updater/src/test/resources/integrationtest/ClaudeUrlUpdater/claude-tags.json
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,9 @@ | ||
| [ | ||
| { | ||
| "ref": "refs/tags/v2.1.118" | ||
| }, | ||
| { | ||
| "ref": "refs/tags/v2.1.118-rc1" | ||
| } | ||
| ] | ||
|
|
Oops, something went wrong.
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.