From 03a1dc973ce026d24e39aebd325d224a198484ef Mon Sep 17 00:00:00 2001 From: pomdtr Date: Fri, 29 Nov 2024 17:24:21 +0100 Subject: [PATCH] remove init command --- .vscode/launch.json | 4 +-- cmd/embed/smallweb/.smallweb/config.json | 3 -- cmd/embed/smallweb/hello-world/main.ts | 13 --------- cmd/init.go | 36 ------------------------ cmd/root.go | 1 - 5 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 cmd/embed/smallweb/.smallweb/config.json delete mode 100644 cmd/embed/smallweb/hello-world/main.ts delete mode 100644 cmd/init.go diff --git a/.vscode/launch.json b/.vscode/launch.json index 026571b..acf8c02 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "up", ], "env": { - "SMALLWEB_DIR": "${workspaceFolder}/cmd/embed/smallweb", + "SMALLWEB_DIR": "${userHome}/smallweb/smallweb.run", "SMALLWEB_DOMAIN": "localhost", }, }, @@ -23,7 +23,7 @@ "doctor" ], "env": { - "SMALLWEB_DIR": "${workspaceFolder}/cmd/embed/smallweb", + "SMALLWEB_DIR": "${userHome}/smallweb/smallweb.run", "SMALLWEB_DOMAIN": "localhost", }, } diff --git a/cmd/embed/smallweb/.smallweb/config.json b/cmd/embed/smallweb/.smallweb/config.json deleted file mode 100644 index 39bbcbe..0000000 --- a/cmd/embed/smallweb/.smallweb/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "domain": "localhost" -} diff --git a/cmd/embed/smallweb/hello-world/main.ts b/cmd/embed/smallweb/hello-world/main.ts deleted file mode 100644 index 1d9841c..0000000 --- a/cmd/embed/smallweb/hello-world/main.ts +++ /dev/null @@ -1,13 +0,0 @@ -export default { - fetch: (req: Request) => { - const url = new URL(req.url); - const name = url.searchParams.get("name") || "smallweb"; - return new Response(`Hello, ${name}!`, { - headers: { "content-type": "text/plain" }, - }); - }, - run: (args: string[]) => { - const name = args[0] || "smallweb"; - console.log(`Hello, ${name}!`); - }, -}; diff --git a/cmd/init.go b/cmd/init.go deleted file mode 100644 index 2965db6..0000000 --- a/cmd/init.go +++ /dev/null @@ -1,36 +0,0 @@ -package cmd - -import ( - "embed" - "fmt" - "os" - - "github.com/pomdtr/smallweb/utils" - "github.com/spf13/cobra" -) - -//go:embed embed/smallweb -var initFS embed.FS - -func NewCmdInit() *cobra.Command { - cmd := &cobra.Command{ - Use: "init", - Hidden: true, - Short: "Initialize smallweb workspace", - RunE: func(cmd *cobra.Command, args []string) error { - rootDir := utils.RootDir() - if _, err := os.Stat(rootDir); !os.IsNotExist(err) { - return fmt.Errorf("smallweb directory already exists: %s", rootDir) - } - - if err := os.CopyFS(rootDir, initFS); err != nil { - return fmt.Errorf("failed to copy template: %w", err) - } - - fmt.Printf("Smallweb dir initialized at %s\n", rootDir) - return nil - }, - } - - return cmd -} diff --git a/cmd/root.go b/cmd/root.go index 373d06f..480dfdc 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -91,7 +91,6 @@ func NewCmdRoot(changelog string) *cobra.Command { cmd.AddCommand(NewCmdCron()) cmd.AddCommand(NewCmdLogs()) cmd.AddCommand(NewCmdSync()) - cmd.AddCommand(NewCmdInit()) cmd.AddCommand(&cobra.Command{ Use: "changelog", Short: "Show the changelog",