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

Add VSCode snippets #150

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions .github/workflows/auto-template-creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ jobs:
include:
# No Fluent or Leaf repo
- repository: template-bare
flags: --no-fluent --no-leaf
flags: --no-fluent --no-leaf --no-vscode
# SQLite repo
- repository: template-fluent-sqlite
flags: --fluent.db sqlite --no-leaf
flags: --fluent.db sqlite --no-leaf --no-vscode
# MySQL repo
- repository: template-fluent-mysql
flags: --fluent.db mysql --no-leaf
flags: --fluent.db mysql --no-leaf --no-vscode
# Postgres repo
- repository: template-fluent-postgres
flags: --fluent.db postgres --no-leaf
flags: --fluent.db postgres --no-leaf --no-vscode
# Postgres with Leaf repo
- repository: template-fluent-postgres-leaf
flags: --fluent.db postgres --leaf
flags: --fluent.db postgres --leaf --no-vscode
runs-on: ubuntu-24.04
steps:
- name: Get token
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
toolbox/vapor new template-test \
--template "${CLONE_URL}" --branch "${HEAD_REF}" \
--no-commit -o template-test \
${{ matrix.fluentflags }} ${{ matrix.leafflags }}
${{ matrix.fluentflags }} ${{ matrix.leafflags }} --no-vscode
- name: Build and test template
run: swift test --package-path template-test
env:
Expand Down Expand Up @@ -154,6 +154,6 @@ jobs:
toolbox/vapor new template-test \
--template "${CLONE_URL}" --branch "${HEAD_REF}" \
--no-commit -o template-test \
${{ matrix.fluentflags }} ${{ matrix.leafflags }}
${{ matrix.fluentflags }} ${{ matrix.leafflags }} --no-vscode
- name: Build Docker container
run: docker compose --project-directory template-test build
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ db.sqlite
.env
.env.*
! .env.example
.vscode
44 changes: 44 additions & 0 deletions .vscode/vapor.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"Endpoint": {
"prefix": "endpoint",
"body": [
"@Sendable",
"func ${1:functionName}(req: Request) async throws -> ${2:returnValue} {",
"\t${3:statements}",
"}"
],
"description": "Vapor: Endpoint function"
},
"AsyncMiddleware": {
"prefix": "middleware",
"body": [
"struct ${1:Name}Middleware: AsyncMiddleware {",
"\tfunc respond(to request: Request, chainingTo next: AsyncResponder) async throws -> Response {",
"\t\t${2:return try await next.respond(to: request)}",
"\t}",
"}"
],
"description": "Vapor: AsyncMiddleware"
},
"req.parameters.get": {
"prefix": "parameter",
"body": [
"req.parameters.get(\"${2:parameterName}\")"
],
"description": "Vapor: Extract parameter from request path"
},
"try req.content.decode": {
"prefix": "decode",
"body": [
"try req.content.decode(${1:Type}.self)"
],
"description": "Vapor: Decode request content"
},
"throw Abort": {
"prefix": "abort",
"body": [
"throw Abort(${code})"
],
"description": "Vapor: throw Abort"
}
}
12 changes: 12 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ variables:
- name: leaf
description: Would you like to use Leaf (templating)?
type: bool
- name: vscode
description: Will you use Visual Studio Code for development?
type: nested
variables:
- name: snippets
description: Would you like to include Visual Studio Code snippets?
type: bool
files:
- file: Package.swift
dynamic: true
Expand Down Expand Up @@ -95,5 +102,10 @@ files:
dynamic: true
- file: docker-compose.yml
dynamic: true
- folder: .vscode
if: vscode
files:
- file: vapor.code-snippets
if: vscode.snippets
- .gitignore
- .dockerignore
Loading