Updates LSP templates (#1375)

This commit is contained in:
Mihovil Ilakovac 2023-07-28 10:33:04 +02:00 committed by GitHub
parent 76d9fc4213
commit 7c09e3964b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -1,6 +1,8 @@
import { {{upperDeclName}} } from '@wasp/actions/types'
{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}}<void, void> = async (args, context) => {
type {{upperDeclName}}Payload = void
type {{upperDeclName}}Result = void
{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}}<{{upperDeclName}}Payload, {{upperDeclName}}Result> = async (args, context) => {
// Implementation goes here
}

View File

@ -1,6 +1,8 @@
import { {{upperDeclName}} } from '@wasp/queries/types'
{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}}<void, void> = async (args, context) => {
type {{upperDeclName}}Payload = void
type {{upperDeclName}}Result = void
{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}}<{{upperDeclName}}Payload, {{upperDeclName}}Result> = async (args, context) => {
// Implementation goes here
}

View File

@ -53,9 +53,9 @@ data-files:
Cli/templates/basic/.wasproot
Cli/templates/basic/src/.waspignore
Cli/templates/basic/main.wasp
lsp/templates/**/*.js
lsp/templates/**/*.ts
lsp/templates/**/*.jsx
Lsp/templates/**/*.js
Lsp/templates/**/*.ts
Lsp/templates/**/*.jsx
packages/deploy/dist/**/*.js
packages/deploy/package.json
packages/deploy/package-lock.json

View File

@ -8,7 +8,7 @@ module Wasp.LSP.Commands.ScaffoldTsSymbol
-- name to end of a particular file.
--
-- Mustache templates are used to write the code for the new function.
-- @templateForRequest@ chooses a template in @data/lsp/template/ts@ based
-- @templateForRequest@ chooses a template in @data/Lsp/template/ts@ based
-- on the location of the external import and the extension of the file that
-- the function will be appended to.
--
@ -192,7 +192,7 @@ hasTemplateForArgs Args {..} = case P.fileExtension $ SP.toPathAbsFile filepath
Just ext -> isRight $ templateFileFor pathToExtImport ext
-- | @getTemplateFor pathToExtImport extension@ finds the mustache template in
-- @data/lsp/templates/ts@ and compiles it.
-- @data/Lsp/templates/ts@ and compiles it.
getTemplateFor :: MonadIO m => ExprPath -> String -> m (Either String Mustache.Template)
getTemplateFor exprPath ext = runExceptT $ do
templatesDir <- liftIO getTemplatesDir
@ -225,7 +225,7 @@ data Template
type TemplateFile = SP.Path' (SP.Rel TemplatesDir) (SP.File Template)
templatesDirInDataDir :: SP.Path' (SP.Rel Wasp.Data.DataDir) (SP.Dir TemplatesDir)
templatesDirInDataDir = [SP.reldir|lsp/templates/ts|]
templatesDirInDataDir = [SP.reldir|Lsp/templates/ts|]
getTemplatesDir :: IO (SP.Path' SP.Abs (SP.Dir TemplatesDir))
getTemplatesDir = (SP.</> templatesDirInDataDir) <$> Wasp.Data.getAbsDataDirPath