From 7b3b0da83f91301420bf9dee34e5c34f1524e73b Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Fri, 29 Nov 2024 21:49:50 +0000 Subject: [PATCH 1/9] =?UTF-8?q?clipboard-data-receiver=20=E3=81=AB=20darwi?= =?UTF-8?q?n=20=E7=94=A8=E3=81=AE=E5=88=86=E5=B2=90=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/clipboard-data-receiver.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/clipboard-data-receiver.go b/tools/clipboard-data-receiver.go index ad85ad8..5d486d6 100644 --- a/tools/clipboard-data-receiver.go +++ b/tools/clipboard-data-receiver.go @@ -15,10 +15,12 @@ import ( ) const CdrFileName = "clipboard-data-receiver" +const CdrFileNameForMac = "clipboard-data-receiver" const cdrFileNameForWindows = "clipboard-data-receiver.exe" // clipboard-data-receiver のダウンロード URL const downloadURLCdrPattern = "https://github.com/mikoto2000/clipboard-data-receiver/releases/download/{{ .TagName }}/clipboard-data-receiver.linux-amd64" +const downloadURLCdrPatternForMac = "https://github.com/mikoto2000/clipboard-data-receiver/releases/download/{{ .TagName }}/clipboard-data-receiver.darwin-amd64" const downloadURLCdrPatternForWindows = "https://github.com/mikoto2000/clipboard-data-receiver/releases/download/{{ .TagName }}/clipboard-data-receiver.windows-amd64.exe" const vimScriptTemplateSendToCdr = `function! SendToCdr(register) abort @@ -39,6 +41,9 @@ var CDR Tool = func() Tool { if util.IsWsl() { cdrFileName = cdrFileNameForWindows tmpl, err = template.New("ducp").Parse(downloadURLCdrPatternForWindows) + } else if runtime.GOOS == "darwin" { + cdrFileName = CdrFileNameForMac + tmpl, err = template.New("ducp").Parse(downloadURLCdrPatternForMac) } else { cdrFileName = CdrFileName tmpl, err = template.New("ducp").Parse(downloadURLCdrPattern) From d224a5253552a6d63b582ae5d542073b5da16c0b Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sat, 30 Nov 2024 01:40:17 +0000 Subject: [PATCH 2/9] =?UTF-8?q?devcontainer=20=E3=81=AB=20darwin=20?= =?UTF-8?q?=E7=94=A8=E3=81=AE=E5=88=86=E5=B2=90=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 ++- tools/devcontainer_darwin.go | 9 +++++++++ .../{devcontainer_nowindows.go => devcontainer_linux.go} | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tools/devcontainer_darwin.go rename tools/{devcontainer_nowindows.go => devcontainer_linux.go} (93%) diff --git a/Makefile b/Makefile index 82356a7..5621ce3 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,8 @@ WATCH_SRC := ./main.go \ ./dockercompose/dockerComposePsResult.go \ ./tools/tools.go \ ./tools/devcontainer.go \ - ./tools/devcontainer_nowindows.go \ + ./tools/devcontainer_darwin.go \ + ./tools/devcontainer_linux.go \ ./tools/devcontainer_windows.go \ ./tools/clipboard-data-receiver.go \ ./util/util.go diff --git a/tools/devcontainer_darwin.go b/tools/devcontainer_darwin.go new file mode 100644 index 0000000..103fede --- /dev/null +++ b/tools/devcontainer_darwin.go @@ -0,0 +1,9 @@ +//go:build darwin + +package tools + +const devcontainerFileName = "devcontainer" + +// devcontainer-cli のダウンロード URL +const downloadURLDevcontainersCliPattern = "https://github.com/mikoto2000/devcontainers-cli/releases/download/{{ .TagName }}/devcontainer-darwin-x64-{{ .TagName }}" + diff --git a/tools/devcontainer_nowindows.go b/tools/devcontainer_linux.go similarity index 93% rename from tools/devcontainer_nowindows.go rename to tools/devcontainer_linux.go index 3cbfd8e..73fb525 100644 --- a/tools/devcontainer_nowindows.go +++ b/tools/devcontainer_linux.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build linux package tools From c978fce8dbe2583e0c728d745a257291610c5b6c Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sat, 30 Nov 2024 16:04:21 +0900 Subject: [PATCH 3/9] Fixed url pattern of darwin devcontainer. --- tools/devcontainer_darwin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/devcontainer_darwin.go b/tools/devcontainer_darwin.go index 103fede..e15943b 100644 --- a/tools/devcontainer_darwin.go +++ b/tools/devcontainer_darwin.go @@ -5,5 +5,5 @@ package tools const devcontainerFileName = "devcontainer" // devcontainer-cli のダウンロード URL -const downloadURLDevcontainersCliPattern = "https://github.com/mikoto2000/devcontainers-cli/releases/download/{{ .TagName }}/devcontainer-darwin-x64-{{ .TagName }}" +const downloadURLDevcontainersCliPattern = "https://github.com/mikoto2000/devcontainers-cli/releases/download/{{ .TagName }}/devcontainer-darwin-arm64-{{ .TagName }}" From caca411ef11c44b86f3ed0641feb40b829cca4ce Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sat, 30 Nov 2024 20:24:51 +0000 Subject: [PATCH 4/9] Rename devcontainer.ExecuteDevcontainer to devcontainer.Start. --- devcontainer/devcontainer.go | 2 +- main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/devcontainer/devcontainer.go b/devcontainer/devcontainer.go index acac90f..b17aa49 100644 --- a/devcontainer/devcontainer.go +++ b/devcontainer/devcontainer.go @@ -31,7 +31,7 @@ func (e *UnknownTypeError) Error() string { // devcontainer でコンテナを立ち上げ、 Vim を転送し、実行する。 // 既存実装の都合上、configFilePath から configDirForDevcontainer を抽出している -func ExecuteDevcontainer(args []string, devcontainerPath string, vimFilePath string, cdrPath, configFilePath string, vimrc string) error { +func Start(args []string, devcontainerPath string, vimFilePath string, cdrPath, configFilePath string, vimrc string) error { vimFileName := filepath.Base(vimFilePath) diff --git a/main.go b/main.go index 6998194..b038858 100644 --- a/main.go +++ b/main.go @@ -327,7 +327,7 @@ func main() { } // devcontainer を用いたコンテナ立ち上げ - err = devcontainer.ExecuteDevcontainer(args, devcontainerPath, vimPath, cdrPath, configFilePath, vimrc) + err = devcontainer.Start(args, devcontainerPath, vimPath, cdrPath, configFilePath, vimrc) if err != nil { if errors.Is(err, os.ErrPermission) { fmt.Fprintf(os.Stderr, "Permission error: %v\n", err) From 06158ae88f1fa738aff046538061f36f9a1da00e Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sat, 30 Nov 2024 20:32:01 +0000 Subject: [PATCH 5/9] =?UTF-8?q?docker.Cp=20=E3=82=92=E4=BD=BF=E3=82=8F?= =?UTF-8?q?=E3=81=9A=E3=81=AB=20`docker=20cp`=20=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=E7=AE=87=E6=89=80=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devcontainer/devcontainer.go | 8 ++------ docker/docker.go | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/devcontainer/devcontainer.go b/devcontainer/devcontainer.go index b17aa49..56df660 100644 --- a/devcontainer/devcontainer.go +++ b/devcontainer/devcontainer.go @@ -71,15 +71,11 @@ func Start(args []string, devcontainerPath string, vimFilePath string, cdrPath, // コンテナへ appimage を転送して実行権限を追加 // `docker cp :/` containerID := upCommandResult.ContainerID - dockerCpArgs := []string{"cp", vimFilePath, containerID + ":/"} - fmt.Printf("Copy AppImage: `%s \"%s\"` ...", containerCommand, strings.Join(dockerCpArgs, "\" \"")) - copyResult, err := exec.Command(containerCommand, dockerCpArgs...).CombinedOutput() + + err = docker.Cp("vim", vimFilePath, containerID, "/") if err != nil { - fmt.Fprintln(os.Stderr, "AppImage copy error.") - fmt.Fprintln(os.Stderr, string(copyResult)) return err } - fmt.Printf(" done.\n") // `docker exec chmod +x /Vim-AppImage` dockerChownArgs := []string{"exec", "--user", "root", containerID, "sh", "-c", "chmod +x /" + vimFileName} diff --git a/docker/docker.go b/docker/docker.go index fbf7a45..6f2e82c 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -222,3 +222,5 @@ func Cp(tagForLog string, from string, containerID string, to string) error { fmt.Printf(" done.\n") return nil } + +// TODO: Exec From b580d88b480e5499c994a15ce901ed5cb2c37ef3 Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sun, 1 Dec 2024 09:20:53 +0900 Subject: [PATCH 6/9] =?UTF-8?q?Apple=20Silicon=20=E7=B3=BB=20macOS=20?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 21 +++++--- README.md | 9 ++-- README_en.md | 8 ++-- devcontainer/devcontainer.go | 10 +--- devcontainer/dockerVimArgs_darwin_arm64.go | 18 +++++++ devcontainer/dockerVimArgs_linux_amd64.go | 16 +++++++ devcontainer/dockerVimArgs_windows_amd64.go | 17 +++++++ tools/tools.go | 33 ------------- tools/vim_darwin_arm64.go | 53 +++++++++++++++++++++ tools/vim_linux_amd64.go | 43 +++++++++++++++++ tools/vim_windows_amd64.go | 44 +++++++++++++++++ 11 files changed, 217 insertions(+), 55 deletions(-) create mode 100644 devcontainer/dockerVimArgs_darwin_arm64.go create mode 100644 devcontainer/dockerVimArgs_linux_amd64.go create mode 100644 devcontainer/dockerVimArgs_windows_amd64.go create mode 100644 tools/vim_darwin_arm64.go create mode 100644 tools/vim_linux_amd64.go create mode 100644 tools/vim_windows_amd64.go diff --git a/Makefile b/Makefile index 5621ce3..7649ecb 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ APP_NAME := devcontainer.vim -GOARCH := amd64 -WINDOWS_BINARY_NAME := ${APP_NAME}-windows-${GOARCH}.exe -LINUX_BINARY_NAME := ${APP_NAME}-linux-${GOARCH} -DARWIN_BINARY_NAME := ${APP_NAME}-darwin-${GOARCH} +GOARCH_AMD64 := amd64 +GOARCH_ARM64 := arm64 +WINDOWS_BINARY_NAME := ${APP_NAME}-windows-${GOARCH_AMD64}.exe +LINUX_BINARY_NAME := ${APP_NAME}-linux-${GOARCH_AMD64} +DARWIN_BINARY_NAME := ${APP_NAME}-darwin-${GOARCH_AMD64} GO_BIN := ${GOPATH}/bin VERSION := 1.3.1 @@ -13,6 +14,9 @@ DEST := ./build WATCH_SRC := ./main.go \ ./devcontainer/DevcontainerJson.go \ ./devcontainer/devcontainer.go \ + ./devcontainer/dockerVimArgs_darwin_arm64.go \ + ./devcontainer/dockerVimArgs_linux_amd64.go \ + ./devcontainer/dockerVimArgs_windows_amd64.go \ ./devcontainer/readConfigurationResult.go \ ./devcontainer/upCommandResult.go \ ./docker/docker.go \ @@ -20,6 +24,9 @@ WATCH_SRC := ./main.go \ ./dockercompose/dockerCompose.go \ ./dockercompose/dockerComposePsResult.go \ ./tools/tools.go \ + ./tools/vim_linux_amd64.go \ + ./tools/vim_darwin_arm64.go \ + ./tools/vim_windows_amd64.go \ ./tools/devcontainer.go \ ./tools/devcontainer_darwin.go \ ./tools/devcontainer_linux.go \ @@ -39,15 +46,15 @@ build-all: build-windows build-linux build-darwin build-windows: build/${WINDOWS_BINARY_NAME} build/${WINDOWS_BINARY_NAME}: ${WATCH_SRC} - GOOS=windows GOARCH=${GOARCH} go build -ldflags=${LD_FLAGS} -trimpath -o build/${WINDOWS_BINARY_NAME} + GOOS=windows GOARCH=${GOARCH_AMD64} go build -ldflags=${LD_FLAGS} -trimpath -o build/${WINDOWS_BINARY_NAME} build-linux: build/${LINUX_BINARY_NAME} build/${LINUX_BINARY_NAME}: ${WATCH_SRC} - GOOS=linux GOARCH=${GOARCH} go build -ldflags=${LD_FLAGS} -trimpath -o build/${LINUX_BINARY_NAME} + GOOS=linux GOARCH=${GOARCH_AMD64} go build -ldflags=${LD_FLAGS} -trimpath -o build/${LINUX_BINARY_NAME} build-darwin: build/${DARWIN_BINARY_NAME} build/${DARWIN_BINARY_NAME}: ${WATCH_SRC} - GOOS=darwin GOARCH=${GOARCH} go build -ldflags=${LD_FLAGS} -trimpath -o build/${DARWIN_BINARY_NAME} + GOOS=darwin GOARCH=${GOARCH_ARM64} go build -ldflags=${LD_FLAGS} -trimpath -o build/${DARWIN_BINARY_NAME} .PHONY: lint lint: diff --git a/README.md b/README.md index b230910..4c12ddf 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ VSCode 向けに作成された `devcontainer.json` に追加する形で Vim - docker +ARM の場合、コンテナ内に `tar` コマンドが存在していること + + ## Usage: ``` @@ -301,9 +304,9 @@ devcontainer.vim runargs -g ## Limitation: -- amd64 のコンテナしか使用できません -- alpine 系のコンテナでは使用できません -- arm 系 macOS では動作しません +- Windows, Linux では、amd64 のコンテナしか使用できません +- amd64 では、 alpine 系のコンテナでは使用できません +- macOS では、arm64 のコンテナしか使用できません ## Install: diff --git a/README_en.md b/README_en.md index d24dab6..708fa4e 100644 --- a/README_en.md +++ b/README_en.md @@ -35,6 +35,8 @@ The following commands are installed and in the PATH. - docker +For ARM, the `tar` command must be present in the container. + ## Usage: @@ -310,9 +312,9 @@ devcontainer.vim runargs -g ## Limitation: -- Only amd64 containers can be used -- Not supported in Alpine-based containers -- Does not work on arm-based macOS +- On Windows and Linux, only amd64 containers can be used. +- On amd64, alpine-based containers cannot be used. +- On macOS, only arm64 containers can be used. ## Install: diff --git a/devcontainer/devcontainer.go b/devcontainer/devcontainer.go index 56df660..124ed8f 100644 --- a/devcontainer/devcontainer.go +++ b/devcontainer/devcontainer.go @@ -112,15 +112,7 @@ func Start(args []string, devcontainerPath string, vimFilePath string, cdrPath, ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() - dockerVimArgs := []string{ - "exec", - "--container-id", - containerID, - "--workspace-folder", - workspaceFolder, - "sh", - "-c", - "cd ~; /" + vimFileName + " --appimage-extract > /dev/null; cd -; ~/squashfs-root/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc"} + dockerVimArgs := DockerVimArgs(containerID, workspaceFolder, vimFileName) fmt.Printf("Start vim: `%s \"%s\"`\n", devcontainerPath, strings.Join(dockerVimArgs, "\" \"")) dockerExec := exec.CommandContext(ctx, devcontainerPath, dockerVimArgs...) dockerExec.Stdin = os.Stdin diff --git a/devcontainer/dockerVimArgs_darwin_arm64.go b/devcontainer/dockerVimArgs_darwin_arm64.go new file mode 100644 index 0000000..9f85766 --- /dev/null +++ b/devcontainer/dockerVimArgs_darwin_arm64.go @@ -0,0 +1,18 @@ +//go:build darwin && arm64 + +package devcontainer + +func DockerVimArgs(containerID string, workspaceFolder string, vimFileName string) []string { + return []string{ + "exec", + "--container-id", + containerID, + "--workspace-folder", + workspaceFolder, + "sh", + "-c", + "cd /; tar zxf ./" + vimFileName + " -C ~/ > /dev/null; cd ~; sudo rm -rf ~/vim-static; mv $(ls -d ~/vim-*-aarch64) ~/vim-static;~/vim-static/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc"} + +} + + diff --git a/devcontainer/dockerVimArgs_linux_amd64.go b/devcontainer/dockerVimArgs_linux_amd64.go new file mode 100644 index 0000000..a1ef104 --- /dev/null +++ b/devcontainer/dockerVimArgs_linux_amd64.go @@ -0,0 +1,16 @@ +//go:build linux && amd64 + +package devcontainer + +func DockerVimArgs(containerID string, workspaceFolder string, vimFileName string) []string { + return []string{ + "exec", + "--container-id", + containerID, + "--workspace-folder", + workspaceFolder, + "sh", + "-c", + "cd ~; /" + vimFileName + " --appimage-extract > /dev/null; cd -; ~/squashfs-root/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc"} + +} diff --git a/devcontainer/dockerVimArgs_windows_amd64.go b/devcontainer/dockerVimArgs_windows_amd64.go new file mode 100644 index 0000000..65ded61 --- /dev/null +++ b/devcontainer/dockerVimArgs_windows_amd64.go @@ -0,0 +1,17 @@ +//go:build windows && amd64 + +package devcontainer + +func DockerVimArgs(containerID string, workspaceFolder string, vimFileName string) []string { + return []string{ + "exec", + "--container-id", + containerID, + "--workspace-folder", + workspaceFolder, + "sh", + "-c", + "cd ~; /" + vimFileName + " --appimage-extract > /dev/null; cd -; ~/squashfs-root/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc"} + +} + diff --git a/tools/tools.go b/tools/tools.go index 26cbeb8..61a2715 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -7,8 +7,6 @@ import ( "os" "path/filepath" "runtime" - "strings" - "text/template" "github.com/mikoto2000/devcontainer.vim/util" ) @@ -54,37 +52,6 @@ func simpleInstall(downloadURL string, filePath string) (string, error) { return filePath, nil } -// Vim のダウンロード URL -const vimDownloadURLPattern = "https://github.com/vim/vim-appimage/releases/download/{{ .TagName }}/Vim-{{ .TagName }}.glibc2.29-x86_64.AppImage" - -// Vim のツール情報 -var VIM Tool = Tool{ - FileName: "vim", - CalculateDownloadURL: func() string { - latestTagName, err := util.GetLatestReleaseFromGitHub("vim", "vim-appimage") - if err != nil { - panic(err) - } - - pattern := "pattern" - tmpl, err := template.New(pattern).Parse(vimDownloadURLPattern) - if err != nil { - panic(err) - } - - tmplParams := map[string]string{"TagName": latestTagName} - var downloadURL strings.Builder - err = tmpl.Execute(&downloadURL, tmplParams) - if err != nil { - panic(err) - } - return downloadURL.String() - }, - installFunc: func(downloadURL string, filePath string) (string, error) { - return simpleInstall(downloadURL, filePath) - }, -} - // 進捗表示用構造体 type ProgressWriter struct { Total int64 diff --git a/tools/vim_darwin_arm64.go b/tools/vim_darwin_arm64.go new file mode 100644 index 0000000..1159f52 --- /dev/null +++ b/tools/vim_darwin_arm64.go @@ -0,0 +1,53 @@ +//go:build darwin + +package tools + +import ( + "strings" + "text/template" + + "github.com/mikoto2000/devcontainer.vim/util" +) + +// Vim のダウンロード URL +const vimDownloadURLPattern = "https://github.com/mikoto2000/vim-static/releases/download/v0.0.0/vim-9.1.0787-aarch64.tar.gz" + +// Vim のツール情報 +var VIM Tool = Tool{ + FileName: "vim", + CalculateDownloadURL: func() string { + latestTagName, err := util.GetLatestReleaseFromGitHub("mikoto2000", "vim-static") + if err != nil { + panic(err) + } + + pattern := "pattern" + tmpl, err := template.New(pattern).Parse(vimDownloadURLPattern) + if err != nil { + panic(err) + } + + tmplParams := map[string]string{"TagName": latestTagName} + var downloadURL strings.Builder + err = tmpl.Execute(&downloadURL, tmplParams) + if err != nil { + panic(err) + } + return downloadURL.String() + }, + installFunc: func(downloadURL string, filePath string) (string, error) { + _, err := simpleInstall(downloadURL, filePath) + if err != nil { + return "", err + } + + // TODO, tar.gz を展開 + //err = util.ExtractTarGz(filePath + ".tar.gz" ,filePath) + //if err != nil { + // return "", err + //} + return filePath, nil + + }, +} + diff --git a/tools/vim_linux_amd64.go b/tools/vim_linux_amd64.go new file mode 100644 index 0000000..a9c55ae --- /dev/null +++ b/tools/vim_linux_amd64.go @@ -0,0 +1,43 @@ +//go:build linux && amd64 + +package tools + +import ( + "strings" + "text/template" + + "github.com/mikoto2000/devcontainer.vim/util" +) + +// Vim のダウンロード URL +const vimDownloadURLPattern = "https://github.com/vim/vim-appimage/releases/download/{{ .TagName }}/Vim-{{ .TagName }}.glibc2.29-x86_64.AppImage" + +// Vim のツール情報 +var VIM Tool = Tool{ + FileName: "vim", + CalculateDownloadURL: func() string { + latestTagName, err := util.GetLatestReleaseFromGitHub("vim", "vim-appimage") + if err != nil { + panic(err) + } + + pattern := "pattern" + tmpl, err := template.New(pattern).Parse(vimDownloadURLPattern) + if err != nil { + panic(err) + } + + tmplParams := map[string]string{"TagName": latestTagName} + var downloadURL strings.Builder + err = tmpl.Execute(&downloadURL, tmplParams) + if err != nil { + panic(err) + } + return downloadURL.String() + }, + installFunc: func(downloadURL string, filePath string) (string, error) { + return simpleInstall(downloadURL, filePath) + }, +} + + diff --git a/tools/vim_windows_amd64.go b/tools/vim_windows_amd64.go new file mode 100644 index 0000000..5f66a21 --- /dev/null +++ b/tools/vim_windows_amd64.go @@ -0,0 +1,44 @@ +//go:build windows && amd64 + +package tools + +import ( + "strings" + "text/template" + + "github.com/mikoto2000/devcontainer.vim/util" +) + +// Vim のダウンロード URL +const vimDownloadURLPattern = "https://github.com/vim/vim-appimage/releases/download/{{ .TagName }}/Vim-{{ .TagName }}.glibc2.29-x86_64.AppImage" + +// Vim のツール情報 +var VIM Tool = Tool{ + FileName: "vim", + CalculateDownloadURL: func() string { + latestTagName, err := util.GetLatestReleaseFromGitHub("vim", "vim-appimage") + if err != nil { + panic(err) + } + + pattern := "pattern" + tmpl, err := template.New(pattern).Parse(vimDownloadURLPattern) + if err != nil { + panic(err) + } + + tmplParams := map[string]string{"TagName": latestTagName} + var downloadURL strings.Builder + err = tmpl.Execute(&downloadURL, tmplParams) + if err != nil { + panic(err) + } + return downloadURL.String() + }, + installFunc: func(downloadURL string, filePath string) (string, error) { + return simpleInstall(downloadURL, filePath) + }, +} + + + From e9a914a3654bba99085cdff8aa45a4744b8630ff Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sun, 1 Dec 2024 11:15:14 +0900 Subject: [PATCH 7/9] Fix typo. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7649ecb..fce7fc7 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOARCH_AMD64 := amd64 GOARCH_ARM64 := arm64 WINDOWS_BINARY_NAME := ${APP_NAME}-windows-${GOARCH_AMD64}.exe LINUX_BINARY_NAME := ${APP_NAME}-linux-${GOARCH_AMD64} -DARWIN_BINARY_NAME := ${APP_NAME}-darwin-${GOARCH_AMD64} +DARWIN_BINARY_NAME := ${APP_NAME}-darwin-${GOARCH_ARM64} GO_BIN := ${GOPATH}/bin VERSION := 1.3.1 From af1a8379698c52c1f94b6004e0144e7555777420 Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sun, 1 Dec 2024 11:18:17 +0900 Subject: [PATCH 8/9] Added TODO on darwin. --- tools/vim_darwin_arm64.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/vim_darwin_arm64.go b/tools/vim_darwin_arm64.go index 1159f52..6764ff8 100644 --- a/tools/vim_darwin_arm64.go +++ b/tools/vim_darwin_arm64.go @@ -10,6 +10,7 @@ import ( ) // Vim のダウンロード URL +// TODO: パターン化 const vimDownloadURLPattern = "https://github.com/mikoto2000/vim-static/releases/download/v0.0.0/vim-9.1.0787-aarch64.tar.gz" // Vim のツール情報 From 776060eb21a77c4804afc570f6cd7275e5b665d1 Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sun, 1 Dec 2024 02:43:03 +0000 Subject: [PATCH 9/9] =?UTF-8?q?darwin=20=E7=89=88=E3=81=A7=E3=82=82?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E3=83=AA=E3=83=AA=E3=83=BC=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E3=83=90=E3=82=A4=E3=83=8A=E3=83=AA=E3=82=92=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/vim_darwin_arm64.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/vim_darwin_arm64.go b/tools/vim_darwin_arm64.go index 6764ff8..4082f60 100644 --- a/tools/vim_darwin_arm64.go +++ b/tools/vim_darwin_arm64.go @@ -10,8 +10,7 @@ import ( ) // Vim のダウンロード URL -// TODO: パターン化 -const vimDownloadURLPattern = "https://github.com/mikoto2000/vim-static/releases/download/v0.0.0/vim-9.1.0787-aarch64.tar.gz" +const vimDownloadURLPattern = "https://github.com/mikoto2000/vim-static/releases/download/{{ .TagName }}/vim-{{ .TagName }}-aarch64.tar.gz" // Vim のツール情報 var VIM Tool = Tool{