From 277fa8b316421dbf07888c9a1e7a22d6f91c2929 Mon Sep 17 00:00:00 2001 From: maddalax Date: Wed, 25 Sep 2024 14:02:10 -0500 Subject: [PATCH] verify install instructions --- .github/workflows/verify-installer-works.yml | 50 ++++++++++++++++++++ cli/htmgo/runner.go | 19 +++++--- 2 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/verify-installer-works.yml diff --git a/.github/workflows/verify-installer-works.yml b/.github/workflows/verify-installer-works.yml new file mode 100644 index 0000000..5a09264 --- /dev/null +++ b/.github/workflows/verify-installer-works.yml @@ -0,0 +1,50 @@ +name: Build and Verify Installer Works + +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the repository + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: Set up Go + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '>=1.20' + + # Step 3: Install htmgo CLI + - name: Install htmgo CLI + run: | + go install github.com/maddalax/htmgo/cli/htmgo@latest + + # Step 4: Generate template using htmgo + - name: Generate myapp template + run: | + htmgo template myapp + + # Step 5: Build the app + - name: Build myapp + run: | + cd myapp + htmgo build + + # Step 6: Verify that the dist directory exists + - name: Verify build output + run: | + if [ ! -d "./myapp/dist" ]; then + echo "Build directory ./dist/myapp does not exist" + exit 1 + fi + shell: bash diff --git a/cli/htmgo/runner.go b/cli/htmgo/runner.go index 222f6fd..8bb4f07 100644 --- a/cli/htmgo/runner.go +++ b/cli/htmgo/runner.go @@ -112,13 +112,18 @@ func main() { _ = css.GenerateCss(process.ExitOnError) _ = run.Server(process.ExitOnError) } else if taskName == "template" { - reader := bufio.NewReader(os.Stdin) - fmt.Print("What would you like to call your new app?: ") - text, _ := reader.ReadString('\n') - text = strings.TrimSuffix(text, "\n") - text = strings.ReplaceAll(text, " ", "-") - text = strings.ToLower(text) - downloadtemplate.DownloadTemplate(fmt.Sprintf("./%s", text)) + name := "" + if len(os.Args) > 2 { + name = os.Args[2] + } else { + reader := bufio.NewReader(os.Stdin) + fmt.Print("What would you like to call your new app?: ") + name, _ = reader.ReadString('\n') + } + name = strings.TrimSuffix(name, "\n") + name = strings.ReplaceAll(name, " ", "-") + name = strings.ToLower(name) + downloadtemplate.DownloadTemplate(fmt.Sprintf("./%s", name)) } else if taskName == "build" { run.Build() } else if taskName == "generate" {