Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisWiegman committed Jun 19, 2024
2 parents b9d701a + 8990716 commit 5cd1418
Show file tree
Hide file tree
Showing 43 changed files with 1,589 additions and 1,060 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ name: "CodeQL"

on:
push:
branches: [ "main", canary ]
branches:
- develop
- main
tags-ignore:
- "**"
pull_request:
branches: [ "main" ]
branches:
- develop
- main
schedule:
- cron: '44 8 * * 3'

# Cancel previous workflow run groups that have not completed.
concurrency:
# Group workflow runs by workflow name, along with the head branch ref of the pull request
# or otherwise the branch or tag ref.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ name: Lint
on:
push:
branches:
- "**"
- develop
- main
tags-ignore:
- "**"
pull_request:
branches:
- "**"
- develop
- main

# Cancel previous workflow run groups that have not completed.
concurrency:
# Group workflow runs by workflow name, along with the head branch ref of the pull request
# or otherwise the branch or tag ref.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
go-test:
golangci-lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ name: Test
on:
push:
branches:
- "**"
- develop
- main
tags-ignore:
- "**"
pull_request:
branches:
- develop
- main

# Cancel previous workflow run groups that have not completed.
concurrency:
# Group workflow runs by workflow name, along with the head branch ref of the pull request
# or otherwise the branch or tag ref.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
go-test:
runs-on: ubuntu-22.04
Expand Down
4 changes: 3 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: 2

project_name: kana

env:
Expand Down Expand Up @@ -46,7 +48,7 @@ snapshot:
name_template: "{{ incpatch .Version }}-devel"

changelog:
skip: false
disable: false

nfpms:
- vendor: Chris Wiegman
Expand Down
34 changes: 7 additions & 27 deletions internal/cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package cmd

import (
"encoding/json"
"fmt"

"github.com/ChrisWiegman/kana/internal/console"
"github.com/ChrisWiegman/kana/internal/site"
"github.com/ChrisWiegman/kana/internal/settings"

"github.com/spf13/cobra"
)

func config(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command {
func config(consoleOutput *console.Console, kanaSettings *settings.Settings) *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Short: "View and edit the saved configuration for the app or the local site.",
Expand All @@ -19,33 +16,16 @@ func config(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command
// This is similar to how setting git options works
switch len(args) {
case 0:
kanaSite.Settings.ListSettings(consoleOutput)
settings.ListSettings(kanaSettings, consoleOutput)
case 1:
value, err := kanaSite.Settings.GetGlobalSetting(args)
if err != nil {
consoleOutput.Error(err)
}
if consoleOutput.JSON {
type JSONSetting struct {
Setting, Value string
}

setting := JSONSetting{
Setting: args[0],
Value: value,
}

str, _ := json.Marshal(setting)

fmt.Println(string(str))
} else {
consoleOutput.Println(value)
}
kanaSettings.PrintSingleSetting(args[0], consoleOutput)
case 2:
err := kanaSite.Settings.SetGlobalSetting(args)
err := kanaSettings.Set(args[0], args[1])
if err != nil {
consoleOutput.Error(err)
}

kanaSettings.PrintSingleSetting(args[0], consoleOutput)
}
},
Args: cobra.RangeArgs(0, 2),
Expand Down
9 changes: 5 additions & 4 deletions internal/cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"

"github.com/ChrisWiegman/kana/internal/console"
"github.com/ChrisWiegman/kana/internal/settings"
"github.com/ChrisWiegman/kana/internal/site"

"github.com/spf13/cobra"
Expand All @@ -13,7 +14,7 @@ import (

var flagForce bool

func destroy(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command {
func destroy(consoleOutput *console.Console, kanaSite *site.Site, kanaSettings *settings.Settings) *cobra.Command {
cmd := &cobra.Command{
Use: "destroy",
Short: "Destroys the current WordPress site. This is a permanent change.",
Expand All @@ -26,7 +27,7 @@ func destroy(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command
confirmDestroy = consoleOutput.PromptConfirm(
fmt.Sprintf(
"Are you sure you want to destroy %s? %s",
consoleOutput.Bold(consoleOutput.Blue(kanaSite.Settings.Name)),
consoleOutput.Bold(consoleOutput.Blue(kanaSettings.Get("Name"))),
consoleOutput.Bold(
consoleOutput.Yellow(
"This operation is destructive and cannot be undone."))),
Expand All @@ -46,7 +47,7 @@ func destroy(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command
}

// Remove the site's folder in the config directory.
err = os.RemoveAll(kanaSite.Settings.SiteDirectory)
err = os.RemoveAll(kanaSettings.Get("Site"))
if err != nil {
consoleOutput.Error(err)
}
Expand All @@ -56,7 +57,7 @@ func destroy(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command
"Your site, %s, has been completely destroyed.",
consoleOutput.Bold(
consoleOutput.Blue(
kanaSite.Settings.Name))))
kanaSettings.Get("Name")))))
return
}

Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"path/filepath"

"github.com/ChrisWiegman/kana/internal/console"
"github.com/ChrisWiegman/kana/internal/settings"
"github.com/ChrisWiegman/kana/internal/site"

"github.com/spf13/cobra"
)

func export(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command {
func export(consoleOutput *console.Console, kanaSite *site.Site, kanaSettings *settings.Settings) *cobra.Command {
cmd := &cobra.Command{
Use: "export",
Short: "Export the current config to a .kana.json file to save with your repo.",
Expand All @@ -32,7 +33,7 @@ func export(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command
consoleOutput.Success(
fmt.Sprintf(
"Your config has been exported to %s",
filepath.Join(kanaSite.Settings.WorkingDirectory, ".kana.json")))
filepath.Join(kanaSettings.Get("Working"), ".kana.json")))
},
Args: cobra.ArbitraryArgs,
}
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/ChrisWiegman/kana/internal/console"
"github.com/ChrisWiegman/kana/internal/settings"
"github.com/ChrisWiegman/kana/internal/site"

"github.com/spf13/cobra"
Expand All @@ -12,7 +13,7 @@ import (

var openDatabaseFlag, openMailpitFlag, openSiteFlag, openAdminFlag bool

func open(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command {
func open(consoleOutput *console.Console, kanaSite *site.Site, kanaSettings *settings.Settings) *cobra.Command {
cmd := &cobra.Command{
Use: "open",
Short: "Open the current site in your browser.",
Expand Down Expand Up @@ -41,7 +42,7 @@ func open(consoleOutput *console.Console, kanaSite *site.Site) *cobra.Command {
"Your site, %s, has been opened in your default browser.",
consoleOutput.Bold(
consoleOutput.Blue(
kanaSite.Settings.Name))))
kanaSettings.Get("Name")))))
},
Args: cobra.NoArgs,
}
Expand Down
20 changes: 12 additions & 8 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"runtime"

"github.com/ChrisWiegman/kana/internal/console"
"github.com/ChrisWiegman/kana/internal/settings"
"github.com/ChrisWiegman/kana/internal/site"

"github.com/spf13/cobra"
Expand All @@ -18,6 +19,7 @@ var (
func Execute() {
kanaSite := new(site.Site)
consoleOutput := new(console.Console)
kanaSettings := new(settings.Settings)

// Setup the cobra command
cmd := &cobra.Command{
Expand All @@ -35,10 +37,12 @@ func Execute() {
}
}

err := kanaSite.New(cmd, commandsRequiringSite, &startFlags, flagVerbose, consoleOutput, Version)
err := settings.Load(kanaSettings, Version, cmd, commandsRequiringSite, &startFlags)
if err != nil {
consoleOutput.Error(err)
}

site.Load(kanaSite, kanaSettings)
},
}

Expand All @@ -58,22 +62,22 @@ func Execute() {
// Register the subcommands
cmd.AddCommand(
changelog(consoleOutput),
config(consoleOutput, kanaSite),
config(consoleOutput, kanaSettings),
db(consoleOutput, kanaSite),
destroy(consoleOutput, kanaSite),
export(consoleOutput, kanaSite),
destroy(consoleOutput, kanaSite, kanaSettings),
export(consoleOutput, kanaSite, kanaSettings),
flush(consoleOutput, kanaSite),
list(consoleOutput, kanaSite),
open(consoleOutput, kanaSite),
start(consoleOutput, kanaSite),
stop(consoleOutput, kanaSite),
open(consoleOutput, kanaSite, kanaSettings),
start(consoleOutput, kanaSite, kanaSettings),
stop(consoleOutput, kanaSite, kanaSettings),
version(consoleOutput),
wp(consoleOutput, kanaSite),
xdebug(consoleOutput, kanaSite),
)

if runtime.GOOS == "darwin" {
cmd.AddCommand(trust(consoleOutput, kanaSite))
cmd.AddCommand(trust(consoleOutput, kanaSettings))
}

// Execute anything we need to
Expand Down
Loading

0 comments on commit 5cd1418

Please sign in to comment.