Compare commits

...

2 commits

Author SHA1 Message Date
Sung Won Cho
f5171dc7ec Reproduce error building windows 2022-04-30 13:28:48 +10:00
Sung Won Cho
cf08ca836a Build CLI 2022-04-29 21:25:11 +10:00
4 changed files with 474 additions and 419 deletions

45
go.mod
View file

@ -3,41 +3,36 @@ module github.com/dnote/dnote
go 1.13 go 1.13
require ( require (
github.com/PuerkitoBio/goquery v1.6.0 // indirect github.com/PuerkitoBio/goquery v1.8.0 // indirect
github.com/andybalholm/cascadia v1.2.0 // indirect
github.com/aymerick/douceur v0.2.0 github.com/aymerick/douceur v0.2.0
github.com/dnote/actions v0.2.0 github.com/dnote/actions v0.2.0
github.com/dnote/color v1.7.0 github.com/dnote/color v1.7.0
github.com/gobuffalo/packr/v2 v2.8.1 github.com/gobuffalo/packr/v2 v2.8.3
github.com/google/go-cmp v0.5.4 github.com/google/go-cmp v0.5.8
github.com/google/go-github v17.0.0+incompatible github.com/google/go-github v17.0.0+incompatible
github.com/google/uuid v1.1.3 github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/csrf v1.6.2 github.com/google/uuid v1.3.0
github.com/gorilla/csrf v1.7.1
github.com/gorilla/css v1.0.0 // indirect
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/gorilla/schema v1.2.0 github.com/gorilla/schema v1.2.0
github.com/jinzhu/gorm v1.9.16 github.com/jinzhu/gorm v1.9.16
github.com/joho/godotenv v1.3.0 github.com/joho/godotenv v1.4.0
github.com/karrick/godirwalk v1.16.1 // indirect github.com/lib/pq v1.10.5
github.com/lib/pq v1.9.0 github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-sqlite3 v1.14.12
github.com/mattn/go-sqlite3 v1.14.6
github.com/nadproject/nad v0.0.0-20200124233812-f1a4e763ee2f
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/radovskyb/watcher v1.0.7 github.com/radovskyb/watcher v1.0.7
github.com/robfig/cron v1.2.0 github.com/robfig/cron v1.2.0
github.com/rogpeppe/go-internal v1.6.2 // indirect github.com/rubenv/sql-migrate v1.1.1
github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351 github.com/sergi/go-diff v1.2.0
github.com/sergi/go-diff v1.1.0 github.com/spf13/cobra v1.4.0
github.com/sirupsen/logrus v1.7.0 // indirect golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f
github.com/spf13/cobra v1.1.1 golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
github.com/yuin/goldmark v1.4.0 golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
golang.org/x/sys v0.0.0-20201231184435-2d18734c6014 // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
) )

771
go.sum

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,6 @@ import (
"github.com/dnote/dnote/pkg/cli/database" "github.com/dnote/dnote/pkg/cli/database"
"github.com/dnote/dnote/pkg/cli/dirs" "github.com/dnote/dnote/pkg/cli/dirs"
"github.com/dnote/dnote/pkg/cli/log" "github.com/dnote/dnote/pkg/cli/log"
"github.com/dnote/dnote/pkg/cli/migrate"
"github.com/dnote/dnote/pkg/cli/utils" "github.com/dnote/dnote/pkg/cli/utils"
"github.com/dnote/dnote/pkg/clock" "github.com/dnote/dnote/pkg/clock"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -111,13 +110,6 @@ func Init(apiEndpoint, versionTag string) (*context.DnoteCtx, error) {
return nil, errors.Wrap(err, "initializing system data") return nil, errors.Wrap(err, "initializing system data")
} }
if err := migrate.Legacy(ctx); err != nil {
return nil, errors.Wrap(err, "running legacy migration")
}
if err := migrate.Run(ctx, migrate.LocalSequence, migrate.LocalMode); err != nil {
return nil, errors.Wrap(err, "running migration")
}
ctx, err = SetupCtx(ctx) ctx, err = SetupCtx(ctx)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "setting up the context") return nil, errors.Wrap(err, "setting up the context")

View file

@ -19,10 +19,14 @@ projectDir="$dir/../.."
basedir="$projectDir/pkg/cli" basedir="$projectDir/pkg/cli"
outputDir="$projectDir/build/cli" outputDir="$projectDir/build/cli"
echo "projectDir: $projectDir"
echo "basedir: $basedir"
echo "outputDir: $projectDir"
# xgo has issues when using modules # xgo has issues when using modules
# https://github.com/karalabe/xgo/issues/176 # https://github.com/karalabe/xgo/issues/176
# bypass it by copying the project inside a GOPATH # bypass it by copying the project inside a GOPATH
goPathBasedir="$GOPATH/src/github.com/dnote/dnote" # g="$GOPATH/src/github.com/dnote/dnote"
command_exists () { command_exists () {
command -v "$1" >/dev/null 2>&1; command -v "$1" >/dev/null 2>&1;
@ -41,7 +45,8 @@ if [[ $1 == v* ]]; then
exit 1 exit 1
fi fi
goVersion=1.13.x goVersion=go-1.17.x
# goVersion=1.17.x
get_binary_name() { get_binary_name() {
platform=$1 platform=$1
@ -65,6 +70,8 @@ build() {
ldflags="-X main.apiEndpoint=https://api.getdnote.com -X main.versionTag=$version" ldflags="-X main.apiEndpoint=https://api.getdnote.com -X main.versionTag=$version"
tags="fts5" tags="fts5"
pushd "$projectDir"
mkdir -p "$destDir" mkdir -p "$destDir"
if [ "$native" == true ]; then if [ "$native" == true ]; then
@ -75,45 +82,53 @@ build() {
-o="$destDir/cli-$platform-$arch" \ -o="$destDir/cli-$platform-$arch" \
"$basedir" "$basedir"
else else
flags=()
if [ "$platform" == "windows" ]; then
flags+=("-buildmode=exe")
fi
xgo \ xgo \
-go "$goVersion" \ -go "$goVersion" \
--targets="$platform/$arch" \ -targets="$platform/$arch" \
-ldflags "$ldflags" \ -ldflags "$ldflags" \
--tags "$tags" \ "${flags[@]}" \
--dest="$destDir" \ -tags "$tags" \
-pkg pkg/cli \
-x \ -x \
-v \ -v \
"$goPathBasedir/pkg/cli" .
fi fi
binaryName=$(get_binary_name "$platform")
mv "$destDir/cli-${platform}-"* "$destDir/$binaryName"
# build tarball
tarballName="dnote_${version}_${platform}_${arch}.tar.gz"
tarballPath="$outputDir/$tarballName"
cp "$projectDir/licenses/GPLv3.txt" "$destDir"
cp "$basedir/README.md" "$destDir"
tar -C "$destDir" -zcvf "$tarballPath" "."
rm -rf "$destDir"
# calculate checksum
pushd "$outputDir"
shasum -a 256 "$tarballName" >> "$outputDir/dnote_${version}_checksums.txt"
popd popd
# binaryName=$(get_binary_name "$platform")
# mv "$destDir/cli-${platform}-"* "$destDir/$binaryName"
#
# # build tarball
# tarballName="dnote_${version}_${platform}_${arch}.tar.gz"
# tarballPath="$outputDir/$tarballName"
#
# cp "$projectDir/licenses/GPLv3.txt" "$destDir"
# cp "$basedir/README.md" "$destDir"
# tar -C "$destDir" -zcvf "$tarballPath" "."
# rm -rf "$destDir"
#
# # calculate checksum
# pushd "$outputDir"
# shasum -a 256 "$tarballName" >> "$outputDir/dnote_${version}_checksums.txt"
# popd
} }
if [ -z "$GOOS" ] && [ -z "$GOARCH" ]; then if [ -z "$GOOS" ] && [ -z "$GOARCH" ]; then
# fetch tool # fetch tool
go get -u github.com/dnote/xgo # go get -u github.com/dnote/xgo
rm -rf "$GOPATH/src/github.com/dnote/dnote" # rm -rf "$GOPATH/src/github.com/dnote/dnote"
cp -R "$projectDir" "$goPathBasedir" # cp -R "$projectDir" "$goPathBasedir"
build linux amd64 # build linux amd64
build linux arm64 # build linux arm64
build darwin amd64 # build darwin amd64
build windows amd64 build windows amd64
else else
build "$GOOS" "$GOARCH" true build "$GOOS" "$GOARCH" true