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

fix: input.css being public #345

Merged
merged 2 commits into from
Dec 16, 2024
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
9 changes: 7 additions & 2 deletions cmd/program/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,19 @@ func (p *Project) CreateMainFile() error {
return err
}

inputCssFile, err := os.Create(fmt.Sprintf("%s/%s/assets/css/input.css", projectPath, cmdWebPath))
err = os.MkdirAll(fmt.Sprintf("%s/%s/styles", projectPath, cmdWebPath), 0o755)
if err != nil {
return fmt.Errorf("failed to create styles directory: %w", err)
}

inputCssFile, err := os.Create(fmt.Sprintf("%s/%s/styles/input.css", projectPath, cmdWebPath))
if err != nil {
return err
}
defer inputCssFile.Close()

inputCssTemplate := advanced.InputCssTemplate()
err = os.WriteFile(fmt.Sprintf("%s/%s/assets/css/input.css", projectPath, cmdWebPath), inputCssTemplate, 0o644)
err = os.WriteFile(fmt.Sprintf("%s/%s/styles/input.css", projectPath, cmdWebPath), inputCssTemplate, 0o644)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/template/advanced/files/docker/dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN go install github.com/a-h/templ/cmd/templ@latest && \
{{- if .AdvancedOptions.tailwind}}
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o tailwindcss && \
chmod +x tailwindcss && \
./tailwindcss -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css
./tailwindcss -i cmd/web/styles/input.css -o cmd/web/assets/css/output.css
{{- end }}

RUN {{ if (eq .DBDriver "sqlite") }}CGO_ENABLED=1 GOOS=linux {{ end }}go build -o main cmd/api/main.go
Expand Down
2 changes: 1 addition & 1 deletion cmd/template/framework/files/makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tailwind-install:
build:{{- if and .AdvancedOptions.tailwind (not .AdvancedOptions.react) }} tailwind-install{{- end }}{{- if and (or .AdvancedOptions.htmx .AdvancedOptions.tailwind) (not .AdvancedOptions.react) }} templ-install{{- end }}
@echo "Building..."
{{ if and (or .AdvancedOptions.htmx .AdvancedOptions.tailwind) (not .AdvancedOptions.react) }}@templ generate{{- end }}
{{ if and .AdvancedOptions.tailwind (not .AdvancedOptions.react) }}@{{ if .OSCheck.UnixBased }}./tailwindcss{{ else }}.\tailwindcss.exe{{ end }} -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css{{ end }}
{{ if and .AdvancedOptions.tailwind (not .AdvancedOptions.react) }}@{{ if .OSCheck.UnixBased }}./tailwindcss{{ else }}.\tailwindcss.exe{{ end }} -i cmd/web/styles/input.css -o cmd/web/assets/css/output.css{{ end }}
{{ if .OSCheck.UnixBased }}@{{- if and (.AdvancedOptions.docker) (eq .DBDriver "sqlite") }}CGO_ENABLED=1 GOOS=linux {{ end }}go build -o main cmd/api/main.go{{- else }}@go build -o main.exe cmd/api/main.go{{- end }}

# Run the application
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/advanced-flag/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN go install github.com/a-h/templ/cmd/templ@latest && \
templ generate && \
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o tailwindcss && \
chmod +x tailwindcss && \
./tailwindcss -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css
./tailwindcss -i cmd/web/styles/input.css -o cmd/web/assets/css/output.css

RUN go build -o main cmd/api/main.go

Expand Down
7 changes: 4 additions & 3 deletions docs/docs/advanced-flag/tailwind.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ The project tree would look like this:
│ ├── api/
│ │ └── main.go
│ └── web/
│ ├── styles/
│ │ └── input.css
│ ├── assets/
│ │ ├── css/
│ │ │ ├── input.css
│ │ │ └── output.css
│ │ └── js/
│ │ └── htmx.min.js
Expand All @@ -24,7 +25,7 @@ The project tree would look like this:
├── internal/
│ └── server/
│ ├── routes.go
│ ├── routes_test.go
│ ├── routes_test.go
│ └── server.go
├── go.mod
├── go.sum
Expand Down Expand Up @@ -64,7 +65,7 @@ tailwind-install:
build: tailwind-install templ-install
@echo "Building..."
@templ generate
@./tailwindcss -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css
@./tailwindcss -i cmd/web/styles/input.css -o cmd/web/assets/css/output.css
@go build -o main cmd/api/main.go
```

Expand Down
5 changes: 3 additions & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ Here's an overview of the project structure created by Go Blueprint when all opt
│ ├── api/
│ │ └── main.go # Main file for starting the server.
│ └── web/
│ ├── styles/ # only for generating css will not be served public
│ │ └── input.css # Tailwind input file for compiling output.css with CLI when HTMX is used
│ ├── assets/
│ │ ├── css/
│ │ │ ├── input.css # Tailwind input file for compiling output.css with CLI when HTMX is used
│ │ │ └── output.css # Generated CSS file.
│ │ └── js/
│ │ └── htmx.min.js # HTMX library for dynamic HTML content.
Expand All @@ -44,7 +45,7 @@ Here's an overview of the project structure created by Go Blueprint when all opt
│ ├── efs.go # Includes assets into compiled binary.
│ ├── hello.go # Logic for handling "hello" form.
│ ├── hello.templ # Template file for the "hello" endpoint.
│ └── hello_templ.go # Generated Go code for the "hello" template.
│ └── hello_templ.go # Generated Go code for the "hello" template.
├── frontend/ # React advanced flag. Excludes HTMX.
│ ├── node_modules/ # Node dependencies.
│ ├── public/
Expand Down
Loading