-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
162 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
go 1.23 | ||
go 1.23.2 | ||
|
||
use ( | ||
./pkg/fyshls | ||
./pkg/go-fysh | ||
./pkg/web-interpreter | ||
./pkg/website-old | ||
./pkg/website/cmd | ||
) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,17 @@ | ||
module github.com/Fysh-Fyve/fysh/pkg/website/cmd | ||
|
||
go 1.23.2 | ||
|
||
require ( | ||
github.com/bitfield/script v0.22.1 | ||
github.com/plus3it/gorecurcopy v0.0.1 | ||
) | ||
|
||
require ( | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/itchyny/gojq v0.12.13 // indirect | ||
github.com/itchyny/timefmt-go v0.1.5 // indirect | ||
golang.org/x/sys v0.19.0 // indirect | ||
golang.org/x/tools v0.16.1 // indirect | ||
mvdan.cc/sh/v3 v3.7.0 // indirect | ||
) |
This file contains 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,24 @@ | ||
github.com/bitfield/script v0.22.1 h1:DphxoC5ssYciwd0ZS+N0Xae46geAD/0mVWh6a2NUxM4= | ||
github.com/bitfield/script v0.22.1/go.mod h1:fv+6x4OzVsRs6qAlc7wiGq8fq1b5orhtQdtW0dwjUHI= | ||
github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA= | ||
github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/itchyny/gojq v0.12.13 h1:IxyYlHYIlspQHHTE0f3cJF0NKDMfajxViuhBLnHd/QU= | ||
github.com/itchyny/gojq v0.12.13/go.mod h1:JzwzAqenfhrPUuwbmEz3nu3JQmFLlQTQMUcOdnu/Sf4= | ||
github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE= | ||
github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8= | ||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= | ||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= | ||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= | ||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= | ||
github.com/plus3it/gorecurcopy v0.0.1 h1:H7AgvM0N/uIo7o1PQRlewEGQ92BNr7DqbPy5lnR3uJI= | ||
github.com/plus3it/gorecurcopy v0.0.1/go.mod h1:NvVTm4RX68A1vQbHmHunDO4OtBLVroT6CrsiqAzNyJA= | ||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= | ||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= | ||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= | ||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= | ||
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= | ||
mvdan.cc/sh/v3 v3.7.0 h1:lSTjdP/1xsddtaKfGg7Myu7DnlHItd3/M2tomOcNNBg= | ||
mvdan.cc/sh/v3 v3.7.0/go.mod h1:K2gwkaesF/D7av7Kxl0HbF5kGOd2ArupNTX3X44+8l8= |
This file contains 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,99 @@ | ||
// Deploy script for github pages | ||
// Loosely based on Docusaurus Github Pages deploy script | ||
// https://github.com/facebook/docusaurus/blob/542228ee1beb5cfddd7ba8ae088f109f164e80c5/packages/docusaurus/src/commands/deploy.ts#L43 | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"path" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/bitfield/script" | ||
"github.com/plus3it/gorecurcopy" | ||
) | ||
|
||
var buildDir = path.Join("dist", "pkg", "website") | ||
|
||
const ( | ||
originUrl = "https://github.com/Fysh-Fyve/Fysh-Fyve.github.io" | ||
projectName = "fysh-five.github.io" | ||
deploymentBranch = "gh-pages" | ||
buildCmd = "" | ||
) | ||
|
||
func execCmd(cmd string) error { | ||
if cmd == "" { | ||
return nil | ||
} | ||
log.Println(cmd) | ||
p := script.Exec(cmd) | ||
p.Stdout() | ||
return p.Error() | ||
} | ||
|
||
func getCmdOutput(cmd string) string { | ||
out, err := script.Exec(cmd).String() | ||
if err != nil { | ||
log.Fatalf("failed command `%s`: %v", cmd, err) | ||
} | ||
return strings.TrimSpace(out) | ||
} | ||
|
||
func mkTmpDir() (string, func()) { | ||
dir, err := os.MkdirTemp(os.TempDir(), projectName+"-"+deploymentBranch) | ||
if err != nil { | ||
log.Fatalf("failed to make temp dir: %v", err) | ||
} | ||
return dir, func() { | ||
if err := os.RemoveAll(dir); err != nil { | ||
log.Printf("failed to remove dir: %v\n", err) | ||
} | ||
} | ||
} | ||
|
||
func dieIf(err error) { | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func main() { | ||
if err := os.RemoveAll("public"); err != nil { | ||
log.Printf("failed to remove dir: %v\n", err) | ||
} | ||
getCmdOutput("git config --get remote.origin.url") | ||
latestHash := getCmdOutput("git rev-parse HEAD") | ||
|
||
dieIf(execCmd(buildCmd)) | ||
|
||
src, err := filepath.Abs(buildDir) | ||
dieIf(err) | ||
gitPublish, cleanGitPublish := mkTmpDir() | ||
defer cleanGitPublish() | ||
|
||
os.Chdir(gitPublish) | ||
cloneCmd := fmt.Sprintf("git clone --depth 1 --branch \"%s\" \"%s\" \"%s\"", deploymentBranch, originUrl, gitPublish) | ||
if err := execCmd(cloneCmd); err != nil { | ||
// Branch doesn't exist, create new branch | ||
dieIf(execCmd("git init")) | ||
dieIf(execCmd("git checkout -b " + deploymentBranch)) | ||
dieIf(execCmd("git remote add origin " + originUrl)) | ||
} else { | ||
dieIf(execCmd("git rm -rf .")) // Simply remove all files | ||
} | ||
if err := gorecurcopy.CopyDirectory(src, gitPublish); err != nil { | ||
log.Fatalf("failed to copy output to publish dir: %v", err) | ||
} | ||
os.Chdir(gitPublish) | ||
dieIf(execCmd("git add --all")) | ||
commitErr := execCmd(fmt.Sprintf("git commit -m \"Deploy website - based on %s\"", latestHash)) | ||
if err := execCmd("git push --force origin " + deploymentBranch); err != nil { | ||
log.Fatalf("failed to push to origin: %v", err) | ||
} else if commitErr == nil { | ||
fmt.Printf("Website is live at: https://%s\n", projectName) | ||
} | ||
} |
This file contains 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
This file contains 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