diff --git a/.goreleaser.yml b/.goreleaser.yml index 7e9fce6..bbfa174 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,14 +1,10 @@ project_name: customrealms-cli -# release: -# github: -# owner: customrealms -# name: cli builds: - id: customrealms-cli-darwin-amd64 ldflags: - -s -w -X github.com/customrealms/cli/pkg/version.Version={{.Version}} binary: crx - main: ./main.go + main: ./cmd/crx/main.go env: - CGO_ENABLED=0 goos: @@ -18,7 +14,7 @@ builds: - id: customrealms-cli-linux-amd64 ldflags: - -s -w -X github.com/customrealms/cli/pkg/version.Version={{.Version}} - main: ./main.go + main: ./cmd/crx/main.go binary: crx env: - CGO_ENABLED=0 @@ -29,7 +25,7 @@ builds: - id: customrealms-cli-windows-amd64 ldflags: - -s -w -X github.com/customrealms/cli/pkg/version.Version={{.Version}} - main: ./main.go + main: ./cmd/crx/main.go binary: crx env: - CGO_ENABLED=0 diff --git a/cmd/crx/main.go b/cmd/crx/main.go new file mode 100644 index 0000000..b798b68 --- /dev/null +++ b/cmd/crx/main.go @@ -0,0 +1,43 @@ +package main + +import ( + "os" + "strings" + + "github.com/customrealms/cli/lib" +) + +const TEMPLATE_JAR = "/Users/conner/Projects/customrealms/bukkit-runtime/target/bukkit-runtime-jar-with-dependencies.jar" +const output = "/Users/conner/Desktop/mcserver/plugins/bukkit-runtime-jar-with-dependencies.jar" + +func main() { + + // Open the output file for the final JAR + file, err := os.Create(output) + if err != nil { + panic(err) + } + defer file.Close() + + // Create a reader for the plugin source code + pluginCode := strings.NewReader("setInterval(() => console.log('YOOOOOO'), 3000)") + + // Define the plugin.yml details for the plugin + pluginYml := lib.PluginYml{ + Name: "MyPlugin", + ApiVersion: "1.17", + Version: "0.0.1", + Main: "io.customrealms.MainPlugin", + } + + // Produce the final JAR file + if err := lib.CreateFinalJar( + file, + TEMPLATE_JAR, + pluginCode, + &pluginYml, + ); err != nil { + panic(err) + } + +} diff --git a/go.mod b/go.mod index 3821038..5b0504f 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/customrealms/crbuild +module github.com/customrealms/cli go 1.17 diff --git a/main.go b/lib/jarbuilder.go similarity index 55% rename from main.go rename to lib/jarbuilder.go index 33869a5..ddf85ec 100644 --- a/main.go +++ b/lib/jarbuilder.go @@ -1,47 +1,11 @@ -package main +package lib import ( "archive/zip" "io" - "os" "strings" ) -const TEMPLATE_JAR = "/Users/conner/Projects/customrealms/bukkit-runtime/target/bukkit-runtime-jar-with-dependencies.jar" -const output = "/Users/conner/Desktop/mcserver/plugins/bukkit-runtime-jar-with-dependencies.jar" - -func main() { - - // Open the output file for the final JAR - file, err := os.Create(output) - if err != nil { - panic(err) - } - defer file.Close() - - // Create a reader for the plugin source code - pluginCode := strings.NewReader("setInterval(() => console.log('YOOOOOO'), 3000)") - - // Define the plugin.yml details for the plugin - pluginYml := PluginYml{ - Name: "MyPlugin", - ApiVersion: "1.17", - Version: "0.0.1", - Main: "io.customrealms.MainPlugin", - } - - // Produce the final JAR file - if err := CreateFinalJar( - file, - TEMPLATE_JAR, - pluginCode, - &pluginYml, - ); err != nil { - panic(err) - } - -} - func CreateFinalJar( writer io.Writer, templateJar string, diff --git a/plugin_yml.go b/lib/pluginyml.go similarity index 97% rename from plugin_yml.go rename to lib/pluginyml.go index 09fb8cd..285822a 100644 --- a/plugin_yml.go +++ b/lib/pluginyml.go @@ -1,4 +1,4 @@ -package main +package lib import ( "fmt"