aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-08-11 19:47:15 -0400
committerXe Iaso <me@xeiaso.net>2023-08-11 19:47:15 -0400
commit6607ca0ec6565130aaec80cc750ce5d3cde15924 (patch)
tree0e058be362304419e21ea23dd95f49ddb34c3f2a
parente50eae921dc8189f8ea34636a77d61897898f019 (diff)
downloadx-6607ca0ec6565130aaec80cc750ce5d3cde15924.tar.xz
x-6607ca0ec6565130aaec80cc750ce5d3cde15924.zip
cmd/yeet: revolutionize a few apps
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--cmd/todayinmarch2020/templates/index.html96
-rw-r--r--cmd/todayinmarch2020/yeetfile.js30
-rw-r--r--cmd/within.website/config.ts37
-rw-r--r--cmd/within.website/yeetfile.js7
-rw-r--r--cmd/yeet/main.go26
-rw-r--r--go.mod1
-rw-r--r--go.sum8
-rw-r--r--internal/appsluggr/appsluggr.go6
8 files changed, 95 insertions, 116 deletions
diff --git a/cmd/todayinmarch2020/templates/index.html b/cmd/todayinmarch2020/templates/index.html
index 1192223..40c326f 100644
--- a/cmd/todayinmarch2020/templates/index.html
+++ b/cmd/todayinmarch2020/templates/index.html
@@ -3,97 +3,11 @@
<head>
<title>What Day of March 2020 Is It?</title>
+ <link rel="stylesheet" href="https://cdn.xeiaso.net/static/pkg/xess/xess.css" />
<style>
- main {
- font-family: monospace, monospace;
- max-width: 38rem;
- padding: 2rem 0;
- margin: auto;
- }
-
- @media only screen and (max-device-width: 736px) {
- main {
- padding: 0rem;
- }
- }
-
- ::selection {
- background: #d3869b;
- }
-
- body {
- background: #282828;
- color: #ebdbb2;
- }
-
- main {
- text-align: center;
- }
-
- pre {
- background-color: #3c3836;
- padding: 1em;
- border: 0;
- }
-
- a,
- a:active,
- a:visited {
- color: #b16286;
- background-color: #1d2021;
- }
-
- h1,
- h2,
- h3,
- h4,
- h5 {
- margin-bottom: .1rem;
- }
-
- blockquote {
- border-left: 1px solid #bdae93;
- margin: 0.5em 10px;
- padding: 0.5em 10px;
- }
-
- footer {
- align: center;
- }
-
- @media (prefers-color-scheme: light) {
- body {
- background: #fbf1c7;
- color: #3c3836;
- }
-
- pre {
- background-color: #ebdbb2;
- padding: 1em;
- border: 0;
- }
-
- a,
- a:active,
- a:visited {
- color: #b16286;
- background-color: #f9f5d7;
- }
-
- h1,
- h2,
- h3,
- h4,
- h5 {
- margin-bottom: .1rem;
- }
-
- blockquote {
- border-left: 1px solid #655c54;
- margin: 0.5em 10px;
- padding: 0.5em 10px;
- }
- }
+ main {
+ text-align: center;
+ }
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
@@ -115,7 +29,7 @@
<footer>
<p>From <a href="https://christine.website">Within</a> - <a
href="https://twitter.com/theprincessxena">@theprincessxena</a> - <a
- href="https://tulpa.dev/cadey/todayinmarch2020">Source Code</a></p>
+ href="https://github.com/Xe/x/tree/master/cmd/todayinmarch2020">Source Code</a></p>
</footer>
</main>
</body>
diff --git a/cmd/todayinmarch2020/yeetfile.js b/cmd/todayinmarch2020/yeetfile.js
new file mode 100644
index 0000000..1abdc68
--- /dev/null
+++ b/cmd/todayinmarch2020/yeetfile.js
@@ -0,0 +1,30 @@
+yeet.setenv("GOOS", "linux");
+yeet.setenv("GOARCH", "amd64");
+yeet.setenv("CGO_ENABLED", "0");
+
+go.build();
+const fname = slug.build("todayinmarch2020");
+
+const url = slug.push(fname);
+const hash = nix.hashURL(url);
+
+const expr = nix.expr`{ stdenv }:
+
+stdenv.mkDerivation {
+ name = "todayinmarch2020";
+ src = builtins.fetchurl {
+ url = ${url};
+ sha256 = ${hash};
+ };
+
+ phases = "installPhase";
+
+ installPhase = ''
+ tar xf $src
+ mkdir -p $out/bin
+ cp bin/main $out/bin/todayinmarch2020
+ '';
+}
+`;
+
+file.write("/home/cadey/code/nixos-configs/pkgs/x/todayinmarch2020.nix", expr);
diff --git a/cmd/within.website/config.ts b/cmd/within.website/config.ts
index e69de29..e79434d 100644
--- a/cmd/within.website/config.ts
+++ b/cmd/within.website/config.ts
@@ -0,0 +1,37 @@
+export interface Repo {
+ kind: "gitea" | "github";
+ domain: string;
+ user: string;
+ repo: string;
+ description: string;
+}
+
+const githubRepo = (name: string, description: string): Repo => {
+ return {
+ kind: "github",
+ domain: "github.com",
+ user: "Xe",
+ repo: name,
+ description,
+ };
+};
+
+const giteaRepo = (name: string, description: string): Repo => {
+ return {
+ kind: "gitea",
+ domain: "tulpa.dev",
+ user: "cadey",
+ repo: name,
+ description,
+ };
+};
+
+const repos: Repo[] = [
+ githubRepo("derpigo", "A Derpibooru/Furbooru API client in Go. This is used to monitor Derpibooru/Furbooru for images by artists I care about and archive them."),
+ githubRepo("eclier", "A command router for Go programs that implements every command in Lua. This was an experiment for making extensible command-line applications with Lua for extending them."),
+ giteaRepo("gopher", "A Gopher (RFC 1436) client/server stack for Go applications. This allows users to write custom Gopher clients and servers."),
+ githubRepo("ln", "The natural log function for Go: an easy package for structured logging. This is the logging stack that I use for most of my personal projects."),
+ githubRepo("x", "Various experimental things. /x/ is my monorepo of side projects, hobby programming, and other explorations of how programming in Go can be."),
+];
+
+export default repos;
diff --git a/cmd/within.website/yeetfile.js b/cmd/within.website/yeetfile.js
index 676443e..b79868c 100644
--- a/cmd/within.website/yeetfile.js
+++ b/cmd/within.website/yeetfile.js
@@ -1,12 +1,13 @@
yeet.setenv("GOOS", "linux");
yeet.setenv("GOARCH", "amd64");
+yeet.setenv("CGO_ENABLED", "0");
go.build();
-slug.build("within.website", {
+const fname = slug.build("within.website", {
"config.ts": "config.ts"
});
-const url = slug.push("within.website");
+const url = slug.push(fname);
const hash = nix.hashURL(url);
const expr = nix.expr`{ stdenv }:
@@ -23,7 +24,7 @@ stdenv.mkDerivation {
installPhase = ''
tar xf $src
mkdir -p $out/bin
- cp web $out/bin/withinwebsite
+ cp bin/main $out/bin/withinwebsite
cp config.ts $out/config.ts
'';
}
diff --git a/cmd/yeet/main.go b/cmd/yeet/main.go
index ed76fe7..76e4140 100644
--- a/cmd/yeet/main.go
+++ b/cmd/yeet/main.go
@@ -11,6 +11,7 @@ import (
"runtime"
"runtime/debug"
"strconv"
+ "strings"
"github.com/dop251/goja"
"golang.org/x/exp/slog"
@@ -90,13 +91,14 @@ func nixbuild(target string) {
runcmd("nix", "build", target)
}
-func slugbuild(bin string, extraFiles map[string]string) {
- appsluggr.Must(bin, fmt.Sprintf("%s-%s.tar.gz", bin, yeet.DateTag), extraFiles)
+func slugbuild(bin string, extraFiles map[string]string) string {
+ result := fmt.Sprintf("%s-%s.tar.gz", bin, yeet.DateTag)
+ appsluggr.Must(bin, result, extraFiles)
os.Remove(bin)
+ return result
}
-func slugpush(bin string) string {
- fname := fmt.Sprintf("%s-%s.tar.gz", bin, yeet.DateTag)
+func slugpush(fname string) string {
fin, err := os.Open(fname)
if err != nil {
panic(err)
@@ -113,20 +115,6 @@ func slugpush(bin string) string {
}
func buildNixExpr(literals []string, exprs ...any) string {
- /*
- function nix(strings, ...expressions) {
- let result = "";
- expressions.forEach((value, i) => {
- let formattedValue = `(builtins.fromJSON ${JSON.stringify(JSON.stringify(value))});`;
- result += `${strings[i]} ${formattedValue}`;
- });
-
- result += strings[strings.length - 1]
-
- return result;
- }
- */
-
result := ""
for i, value := range exprs {
formattedValue, _ := json.Marshal(value)
@@ -203,7 +191,7 @@ func main() {
vm.Set("nix", map[string]any{
"build": nixbuild,
- "hashURL": func(fileURL string) string { return runcmd("nix-prefetch-url", fileURL) },
+ "hashURL": func(fileURL string) string { return strings.TrimSpace(runcmd("nix-prefetch-url", fileURL)) },
"expr": buildNixExpr,
"eval": evalNixExpr,
})
diff --git a/go.mod b/go.mod
index 8c2b898..c212245 100644
--- a/go.mod
+++ b/go.mod
@@ -66,6 +66,7 @@ require (
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/miekg/dns v1.1.55 // indirect
+ github.com/odysseus/vigenere v0.0.0-20160229231241-ef60629652ab // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
diff --git a/go.sum b/go.sum
index 740248d..272e072 100644
--- a/go.sum
+++ b/go.sum
@@ -205,6 +205,7 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
@@ -373,15 +374,18 @@ github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwA
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86 h1:elKwZS1OcdQ0WwEDBeqxKwb7WB62QX8bvZ/FJnVXIfk=
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86/go.mod h1:aFAMtuldEgx/4q7iSGazk22+IcgvtiC+HIimFO9XlS8=
+github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/jsimonetti/rtnetlink v1.3.2 h1:dcn0uWkfxycEEyNy0IGfx3GrhQ38LH7odjxAghimsVI=
github.com/jsimonetti/rtnetlink v1.3.2/go.mod h1:BBu4jZCpTjP6Gk0/wfrO8qcqymnN3g0hoFqObRmUo6U=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
@@ -436,9 +440,13 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mymmrac/telego v0.26.0 h1:m4B3SW9dxL4uHpyjBnmhQeiFO7GWCxFjsUKUvFx3mf0=
github.com/mymmrac/telego v0.26.0/go.mod h1:kizipjY3MhxmkcGvyz8jiw/26vEKAhR2V7YTE69iqvw=
+github.com/odysseus/vigenere v0.0.0-20160229231241-ef60629652ab h1:Sl0OnN8DN3BAyVvCqUFuPWBEG3Zi+Fn0KI3jw3TYZG4=
+github.com/odysseus/vigenere v0.0.0-20160229231241-ef60629652ab/go.mod h1:wVHqV45KjNU7r3KSEjlcnj/TZAOcQsMSDh4OtGCI+1U=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
diff --git a/internal/appsluggr/appsluggr.go b/internal/appsluggr/appsluggr.go
index 7fd1732..350ee9d 100644
--- a/internal/appsluggr/appsluggr.go
+++ b/internal/appsluggr/appsluggr.go
@@ -12,6 +12,7 @@ import (
"github.com/otiai10/copy"
"github.com/rogpeppe/go-internal/dirhash"
+ "golang.org/x/exp/slog"
)
// Must calls Pack and panics on an error.
@@ -52,14 +53,13 @@ func Pack(fname string, outFname string, extraFiles ...map[string]string) error
for _, finfo := range extraFiles {
for src, dst := range finfo {
- if err := copy.Copy(src, dst); err != nil {
+ slog.Debug("copying file", "src", src, "dst", dst)
+ if err := copy.Copy(src, filepath.Join(dir, dst)); err != nil {
return err
}
}
}
- copy.Copy("config.ts", dir)
-
if err := os.WriteFile(filepath.Join(dir, "Procfile"), []byte("web: /app/bin/main\n"), 0777); err != nil {
return err
}