Remove teldrive-ui submodule

This commit is contained in:
divyam234 2024-04-19 02:25:07 +05:30
parent 6364f86571
commit 1829ab35a9
6 changed files with 23 additions and 29 deletions

View file

@ -22,10 +22,6 @@ jobs:
with:
go-version: stable
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:

4
.gitignore vendored
View file

@ -29,4 +29,6 @@ sslcerts
*.env.staging
*.db
logs
bin
bin
ui/dist
teldrive-ui.zip

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "ui/teldrive-ui"]
path = ui/teldrive-ui
url = https://github.com/divyam234/teldrive-ui

View file

@ -1,7 +1,7 @@
FRONTEND_DIR := ui/teldrive-ui
BUILD_DIR := bin
APP_NAME := teldrive
BUILD_DIR := bin
FRONTEND_DIR := ui/dist
FRONTEND_ASSET := https://github.com/divyam234/teldrive-ui/releases/download/v1/teldrive-ui.zip
GIT_TAG := $(shell git describe --tags --abbrev=0)
GIT_COMMIT := $(shell git rev-parse --short HEAD)
GIT_LINK := $(shell git remote get-url origin)
@ -23,17 +23,23 @@ SHELL := /bin/bash
BINARY_EXTENSION:=
endif
frontend: $(ENV_FILE)
@echo "Building frontend..."
cd $(FRONTEND_DIR) ; pnpm install ; pnpm build
$(ENV_FILE): Makefile
ifdef ComSpec
@echo 'VITE_VERSION_INFO={"version": "$(GIT_TAG)", "commit": "$(GIT_COMMIT)", "link": "$(GIT_LINK)"}' | Out-File -encoding utf8 $(ENV_FILE)
frontend:
@echo "Extract UI"
ifeq ($(OS),Windows_NT)
powershell -Command "Remove-Item -Path $(FRONTEND_DIR) -Recurse -Force"
powershell -Command "Invoke-WebRequest -Uri $(FRONTEND_ASSET) -OutFile teldrive-ui.zip"
powershell -Command "if (!(Test-Path -Path $(subst /,\\,$(FRONTEND_DIR)))) { New-Item -ItemType Directory -Force -Path $(subst /,\\,$(FRONTEND_DIR)) }"
powershell -Command "Expand-Archive -Path teldrive-ui.zip -DestinationPath $(FRONTEND_DIR) -Force"
powershell -Command "Remove-Item -Path teldrive-ui.zip -Force"
else
@echo 'VITE_VERSION_INFO={"version": "$(GIT_TAG)", "commit": "$(GIT_COMMIT)", "link": "$(GIT_LINK)"}' > $(ENV_FILE)
rm -rf $(FRONTEND_DIR)
curl -LO $(FRONTEND_ASSET) -o teldrive-ui.zip
mkdir -p $(FRONTEND_DIR)
unzip -d $(FRONTEND_DIR) teldrive-ui.zip
rm -rf teldrive-ui.zip
endif
backend:
@echo "Building backend for $(GOOS)/$(GOARCH)..."
go build -trimpath -ldflags "-s -w -X $(MODULE_PATH)/internal/config.Version=$(GIT_TAG) -extldflags=-static" -o $(BUILD_DIR)/$(APP_NAME)$(BINARY_EXTENSION)
@ -54,12 +60,6 @@ deps:
@echo "Installing Go dependencies..."
go mod download
@echo "Installing frontend dependencies..."
cd $(FRONTEND_DIR) && pnpm install
sync-ui:
git submodule update --init --recursive --remote
retag:
@echo "Retagging..."
git tag -d $(GIT_TAG)

@ -1 +0,0 @@
Subproject commit cdd8c6a7cf04ac72164c5b212d7a13b75041b1c0

View file

@ -11,7 +11,7 @@ import (
"github.com/gin-gonic/gin"
)
//go:embed all:teldrive-ui/dist
//go:embed all:dist
var staticFS embed.FS
func AddRoutes(router gin.IRouter) {
@ -28,7 +28,7 @@ type staticFileSystem struct {
var _ static.ServeFileSystem = (*staticFileSystem)(nil)
func newStaticFileSystem() *staticFileSystem {
sub, err := fs.Sub(staticFS, "teldrive-ui/dist")
sub, err := fs.Sub(staticFS, "dist")
if err != nil {
panic(err)
@ -40,7 +40,7 @@ func newStaticFileSystem() *staticFileSystem {
}
func (s *staticFileSystem) Exists(prefix string, path string) bool {
buildpath := fmt.Sprintf("teldrive-ui/dist%s", path)
buildpath := fmt.Sprintf("dist%s", path)
if strings.HasSuffix(path, "/") {
_, err := staticFS.ReadDir(strings.TrimSuffix(buildpath, "/"))