Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.build
/node_modules/
/bin/
/data/
/pkg/web/ui
66 changes: 45 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,54 @@
CPP = /usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C -Wno-invalid-pp-token
SHA := $(shell git rev-parse HEAD)

SRC = $(shell find web/assets -maxdepth 1 -type f)
DST = $(patsubst %.scss,%.css,$(patsubst %.ts,%.js,$(subst web/assets,.build/assets,$(SRC))))
all: bin/golinks

ALL: web/bindata.go
bin/golinks: $(shell find pkg -type f) pkg/web/ui/build
go build -o $@ ./cmd/golinks

.build/bin/go-bindata:
GOPATH=$(shell pwd)/.build go get github.com/a-urth/go-bindata/...
pkg/web/ui/build: node_modules/build $(shell find ui -type f) vite.config.js
npm run build
echo $(SHA) > $@

.build/assets:
mkdir -p $@
node_modules/build:
npm install --verbose
touch $@

.build/assets/%.css: web/assets/%.scss
sass --no-source-map --style=compressed $< $@
test:
go test ./pkg/...
# CPP = /usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C -Wno-invalid-pp-token

.build/assets/%.js: web/assets/%.ts
$(eval TMP := $(shell mktemp))
tsc --out $(TMP) $<
closure-compiler --js $(TMP) --js_output_file $@
rm -f $(TMP)
# SRC = $(shell find web/assets -maxdepth 1 -type f)
# DST = $(patsubst %.scss,%.css,$(patsubst %.ts,%.js,$(subst web/assets,.build/assets,$(SRC))))

.build/assets/%: web/assets/%
cp $< $@
# ALL: web/bindata.go

web/bindata.go: .build/bin/go-bindata .build/assets $(DST)
$< -o $@ -pkg web -prefix .build/assets -nomemcopy .build/assets/...
# .build/bin/go-bindata:
# GOPATH=$(shell pwd)/.build go get github.com/a-urth/go-bindata/...

clean:
rm -rf .build/assets web/bindata.go
# .build/assets:
# mkdir -p $@

# .build/assets/%.css: web/assets/%.scss node_modules/build
# npx sass --no-source-map --style=compressed $< $@

# .build/assets/%.js: web/assets/%.ts node_modules/build closure-compiler.jar
# $(eval TMP := $(shell mktemp))
# npx tsc --out $(TMP) --ignoreDeprecations 5.0 $<
# java -jar closure-compiler.jar --js $(TMP) --js_output_file $@
# rm -f $(TMP)

# .build/assets/%: web/assets/%
# cp $< $@

# node_modules/build:
# npm install --verbose
# touch $@

# closure-compiler.jar:
# curl -L -o $@ https://repo1.maven.org/maven2/com/google/javascript/closure-compiler/v20230802/closure-compiler-v20230802.jar

# web/bindata.go: .build/bin/go-bindata .build/assets $(DST)
# $< -o $@ -pkg web -prefix .build/assets -nomemcopy .build/assets/...

# clean:
# rm -rf .build/assets web/bindata.go
59 changes: 0 additions & 59 deletions cmd/go/main.go

This file was deleted.

50 changes: 50 additions & 0 deletions cmd/golinks/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main

import "github.com/kellegous/golinks/pkg/cli"

func main() {
cli.Execute()
}

// func main() {
// pflag.String("addr", ":8067", "default bind address")
// pflag.Bool("admin", false, "allow admin-level requests")
// pflag.String("version", "", "version string")
// pflag.String("backend", "leveldb", "backing store to use. 'leveldb' and 'firestore' currently supported.")
// pflag.String("data", "data", "The location of the leveldb data directory")
// pflag.String("project", "", "The GCP project to use for the firestore backend. Will attempt to use application default creds if not defined.")
// pflag.String("host", "", "The host field to use when gnerating the source URL of a link. Defaults to the Host header of the generate request")
// pflag.Parse()

// if err := viper.BindPFlags(pflag.CommandLine); err != nil {
// log.Panic(err)
// }

// // allow env vars to set pflags
// viper.AutomaticEnv()
// viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))

// var backend backend.Backend

// switch viper.GetString("backend") {
// case "leveldb":
// var err error
// backend, err = leveldb.New(viper.GetString("data"))
// if err != nil {
// log.Panic(err)
// }
// case "firestore":
// var err error

// backend, err = firestore.New(context.Background(), viper.GetString("project"))
// if err != nil {
// log.Panic(err)
// }
// default:
// log.Panic(fmt.Sprintf("unknown backend %s", viper.GetString("backend")))
// }

// defer backend.Close()

// log.Panic(web.ListenAndServe(backend))
// }
61 changes: 53 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,59 @@
module github.com/kellegous/go
module github.com/kellegous/golinks

go 1.13
go 1.21.3

require (
cloud.google.com/go v0.38.0
github.com/googleapis/gax-go v2.0.2+incompatible // indirect
cloud.google.com/go/firestore v1.13.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.5.0
github.com/spf13/viper v1.17.0
github.com/syndtr/goleveldb v1.0.0
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
google.golang.org/api v0.14.0
google.golang.org/grpc v1.21.0
golang.org/x/oauth2 v0.13.0
google.golang.org/api v0.147.0
google.golang.org/grpc v1.58.3
)

require (
cloud.google.com/go v0.110.8 // indirect
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/longrunning v0.5.1 // indirect
github.com/a-urth/go-bindata v0.0.0-20180209162145-df38da164efc // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading