Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Sep 12, 2023
2 parents 9ccec06 + b6a7de4 commit 7a28fb9
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 931 deletions.
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 1 addition & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,20 @@ go 1.21

require (
github.com/gofiber/fiber/v2 v2.49.1
github.com/gofiber/template v1.6.29
github.com/pterm/pterm v0.12.67
go.etcd.io/bbolt v1.3.7
)

require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/tinylib/msgp v1.1.8 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.49.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
)
906 changes: 3 additions & 903 deletions go.sum

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions internal/pkg/handlers/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/gofiber/fiber/v2"
"github.com/pterm/pterm"
"go.etcd.io/bbolt"

"github.com/installer/instl/internal/pkg/config"
Expand All @@ -17,7 +16,10 @@ var db *bbolt.DB

func init() {
dbTmp, err := bbolt.Open("./metrics.db", 0666, nil)
pterm.Fatal.PrintOnError(err)
if err != nil {
panic(err)
}

db = dbTmp
}

Expand Down
25 changes: 17 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"github.com/gofiber/fiber/v2/log"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/installer/instl/templates"
"os"
Expand All @@ -13,12 +14,9 @@ import (
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/installer/instl/internal/pkg/config"
"github.com/installer/instl/internal/pkg/handlers"
"github.com/installer/instl/internal/pkg/platforms"
"github.com/installer/instl/scripts"
"github.com/pterm/pterm"
"github.com/pterm/pterm/putils"

"github.com/installer/instl/internal/pkg/handlers"
)

func main() {
Expand All @@ -31,20 +29,31 @@ func main() {
// Check if test flag is set
if *test {
platform, err := platforms.Parse(runtime.GOOS)
pterm.Fatal.PrintOnError(err)
if err != nil {
log.Fatal(err)
}

script, err := scripts.ParseTemplateForPlatform(platform, config.Config{
Owner: *owner,
Repo: *repo,
Version: "latest",
CreatedAt: time.Now(),
Verbose: *verbose,
})
pterm.Fatal.PrintOnError(err)
if err != nil {
log.Fatal(err)
}

fmt.Println(script)
os.Exit(0)
}

pterm.DefaultBigText.WithLetters(putils.LettersFromString(" INSTL")).Render()
fmt.Println(` ██ ███ ██ ███████ ████████ ██
██ ████ ██ ██ ██ ██
██ ██ ██ ██ ███████ ██ ██
██ ██ ██ ██ ██ ██ ██
██ ██ ████ ███████ ██ ███████
`)

engine := templates.New()
app := fiber.New(fiber.Config{
Expand Down Expand Up @@ -85,5 +94,5 @@ func main() {
app.Get("/:user/:repo/:os", handlers.Installation)
app.Get("/:user/:repo/:os/verbose", handlers.InstallationVerbose)

pterm.Fatal.PrintOnError(app.Listen(":80"))
log.Fatal(app.Listen(":80"))
}
7 changes: 4 additions & 3 deletions scripts/assets/linux/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ done
verbose "Finding asset with highest score"
maxScore=0
maxKey=""
for key in $(map_keys assets); do
score="$(map_get assets "$key")"
for asset in $(map_keys assets); do
score="$(map_get assets "$asset")"
if [ $score -gt $maxScore ]; then
maxScore=$score
maxKey=$key
maxKey=$asset
fi
verbose "Asset: $asset, score: $score"
done

assetName="$maxKey"
Expand Down
34 changes: 34 additions & 0 deletions templates/home.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
</header>

<article>
<blockquote>
Instl is an installation script generator for GitHub projects. It does not need any setup, and can be used to install most GitHub projects on Linux, macOS and Windows.<br/>
You can easily add installation commands to your <code>README</code> - they just work!.
</blockquote>
<form>
<div class="grid">
<label for="owner">
GitHub user
<input type="text" id="owner" name="lastname" placeholder="GitHub user" required>
</label>
<label for="repo">
Repository
<input type="text" id="repo" name="firstname" placeholder="Repository" required>
</label>
</div>

<button type="submit" id="submit">Create Installer Scripts</button>
</form>

<h2>Key Features</h2>
<ul>
<li>💻 Cross-Platform: Works on Windows, macOS and Linux out of the box</li>
Expand Down Expand Up @@ -61,4 +80,19 @@
</p>
</article>

<script lang="js">
const form = document.querySelector('form');
const submit = document.querySelector('#submit');

form.addEventListener('submit', (e) => {
e.preventDefault();
submit.disabled = true;
submit.innerText = 'Generating...';

const owner = document.querySelector('#owner').value;
const repo = document.querySelector('#repo').value;

document.location = `/${owner}/${repo}`;
});
</script>
{{end}}
36 changes: 36 additions & 0 deletions templates/repo.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,42 @@
</tbody>
</table>

<hgroup>
<h2>Markdown</h2>
<p>Markdown presets for your <code>README</code>!</p>
</hgroup>

<h3>Table</h3>
<pre><code>
| Platform | Command |
| -------- | ------- |
| Windows | <code>iwr instl.sh/{{.Owner}}/{{.Repo}}/windows | iex</code> |
| macOS | <code>curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/macos | bash</code> |
| Linux | <code>curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/linux | bash</code> |

> [📊 Install stats](https://instl.sh/{{.Owner}}/{{.Repo}})
</code></pre>

<h3>Headings</h3>
<pre><code>
#### Windows
```powershell
iwr instl.sh/{{.Owner}}/{{.Repo}}/windows | iex
```

#### macOS
```bash
curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/macos | bash
```

#### Linux
```bash
curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/linux | bash
```

> [📊 Install stats](https://instl.sh/{{.Owner}}/{{.Repo}})
</code></pre>

</article>

<script lang="js">
Expand Down

0 comments on commit 7a28fb9

Please sign in to comment.