Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devcontainer and bump dependencies #3

Merged
merged 2 commits into from
Feb 10, 2025
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:1.23-bookworm",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"installYarnUsingApt": true,
"version": "lts",
"pnpmVersion": "latest",
"nvmVersion": "latest"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "1.23.6"
}
},
"customizations": {
"vscode": {
"extensions": [
"timonwong.shellcheck",
"ms-vscode.makefile-tools",
"github.vscode-github-actions",
"ms-azuretools.vscode-docker",
"golang.go"
],
"settings": {
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8080
],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "echo deb http://deb.debian.org/debian bookworm-backports main | sudo tee -a /etc/apt/sources.list.d/bookworm-backports.list && sudo apt-get update && sudo apt install -y libwebp-dev/bookworm-backports && npm install"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
shell: msys2 {0}
run: |
set MSYSTEM=MINGW64
curl -LO https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-libwebp-1.2.4-4-any.pkg.tar.zst
pacman -U --noconfirm mingw-w64-x86_64-libwebp-1.2.4-4-any.pkg.tar.zst
curl -LO https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-libwebp-1.5.0-1-any.pkg.tar.zst
pacman -U --noconfirm mingw-w64-x86_64-libwebp-1.5.0-1-any.pkg.tar.zst

- name: Install frontend dependencies
run: npm install
Expand Down
4 changes: 2 additions & 2 deletions cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os"

Expand Down Expand Up @@ -60,7 +60,7 @@ func delete(cmd *cobra.Command, args []string) error {

if resp.StatusCode != 200 {
fmt.Printf("Tidbyt API returned status %s\n", resp.Status)
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
return fmt.Errorf("Tidbyt API returned status: %s", resp.Status)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"

Expand Down Expand Up @@ -45,7 +45,7 @@ func devices(cmd *cobra.Command, args []string) {

if resp.StatusCode != 200 {
fmt.Printf("Tidbyt API returned status %s\n", resp.Status)
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
os.Exit(1)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"text/tabwriter"
Expand Down Expand Up @@ -66,7 +66,7 @@ func listInstallations(cmd *cobra.Command, args []string) error {
return fmt.Errorf("listing installations from API: %w", err)
}

body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode != 200 {
fmt.Printf("Tidbyt API returned status %s\n", resp.Status)
fmt.Println(string(body))
Expand Down
8 changes: 4 additions & 4 deletions cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"

Expand Down Expand Up @@ -56,7 +56,7 @@ func push(cmd *cobra.Command, args []string) error {
}

if background && len(installationID) == 0 {
return fmt.Errorf("Background push won't do anything unless you also specify an installation ID")
return fmt.Errorf("Background push won't do anything unless you also specify an installation ID")
}

if apiToken == "" {
Expand All @@ -71,7 +71,7 @@ func push(cmd *cobra.Command, args []string) error {
return fmt.Errorf("blank Tidbyt API token (use `pixlet login`, set $%s or pass with --api-token)", APITokenEnv)
}

imageData, err := ioutil.ReadFile(image)
imageData, err := os.ReadFile(image)
if err != nil {
return fmt.Errorf("failed to read file %s: %w", image, err)
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func push(cmd *cobra.Command, args []string) error {

if resp.StatusCode != 200 {
fmt.Printf("Tidbyt API returned status %s\n", resp.Status)
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
return fmt.Errorf("Tidbyt API returned status: %s", resp.Status)
}
Expand Down
28 changes: 16 additions & 12 deletions cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package cmd

import (
"context"
"encoding/json"
"fmt"
"image"
"io"
"io/fs"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"time"
"encoding/json"
"log"

"github.com/spf13/cobra"
"tidbyt.dev/pixlet/encode"
"tidbyt.dev/pixlet/globals"
Expand All @@ -20,7 +21,7 @@ import (
)

var (
configJson string
configJson string
output string
magnify int
renderGif bool
Expand All @@ -32,7 +33,7 @@ var (
)

func init() {
RenderCmd.Flags().StringVarP(&configJson,"config","c","","Config file in json format")
RenderCmd.Flags().StringVarP(&configJson, "config", "c", "", "Config file in json format")
RenderCmd.Flags().StringVarP(&output, "output", "o", "", "Path for rendered image")
RenderCmd.Flags().BoolVarP(&renderGif, "gif", "", false, "Generate GIF instead of WebP")
RenderCmd.Flags().BoolVarP(&silenceOutput, "silent", "", false, "Silence print statements when rendering app")
Expand Down Expand Up @@ -127,20 +128,23 @@ func render(cmd *cobra.Command, args []string) error {
// Open the JSON file.
file, err := os.Open(configJson)
if err != nil {
return fmt.Errorf("file open error %v",err)
return fmt.Errorf("file open error %v", err)
}

// Use the `json.Unmarshal()` function to unmarshal the JSON file into the map variable.
fileData, err := ioutil.ReadAll(file)
fileData, err := io.ReadAll(file)
if err != nil {
return fmt.Errorf("file read error %v", err)
}
err = json.Unmarshal(fileData, &config)
if err != nil {
return fmt.Errorf("somewthing wrong with json %v",configJson)
return fmt.Errorf("something wrong with json %v", configJson)
}
log.Printf("got json config of %v",config)

log.Printf("got json config of %v", config)

} else {

for _, param := range args[1:] {
split := strings.Split(param, "=")
if len(split) < 2 {
Expand Down
Loading
Loading