-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat(nuxt): add nuxt template settings #875
Open
Tahul
wants to merge
4
commits into
edgedb:master
Choose a base branch
from
Tahul:feat/nuxt-template
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4fa5028
feat(nuxt): add nuxt template settings
Tahul d4e8db6
feat(nuxt): import playground from nuxt-edgedb-module
Tahul 0843c3b
chore(revert): revert extraneous change on nextjs
Tahul 7700b0e
fix(nuxt): move nuxt-edgedb-modbule to `dependencies` and use stricte…
Tahul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import path from "node:path"; | ||
import debug from "debug"; | ||
import { updatePackage } from "write-package"; | ||
|
||
import type { BaseOptions, Recipe } from "../types.js"; | ||
import { copyTemplateFiles } from "../../utils.js"; | ||
|
||
const logger = debug("@edgedb/create:recipe:nuxt"); | ||
|
||
// interface NuxtOptions {} | ||
|
||
const recipe: Recipe = { | ||
skip(opts: BaseOptions) { | ||
return opts.framework !== "nuxt"; | ||
}, | ||
async apply( | ||
{ projectDir }: BaseOptions, | ||
) { | ||
logger("Running nuxt recipe"); | ||
|
||
const dirname = path.dirname(new URL(import.meta.url).pathname); | ||
|
||
await copyTemplateFiles( | ||
path.resolve(dirname, 'template'), | ||
projectDir | ||
); | ||
|
||
await updatePackage(projectDir, { | ||
type: 'module', | ||
scripts: { | ||
dev: "nuxi dev", | ||
build: "nuxi build", | ||
start: "nuxi start", | ||
generate: "nuxi generate" | ||
}, | ||
dependencies: { | ||
"@iconify-json/heroicons": "1.1.19", | ||
"@nuxt/ui": "^2.13.0", | ||
"nuxt-edgedb-module": "^0.0.42" | ||
}, | ||
devDependencies: { | ||
"@edgedb/generate": "0.4.1", | ||
"@nuxt/devtools": "latest", | ||
"nuxt": "latest" | ||
}, | ||
}); | ||
}, | ||
}; | ||
|
||
export default recipe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<script setup lang="ts"> | ||
const { isLoggedIn } = useEdgeDbIdentity() | ||
|
||
const links = computed(() => { | ||
const links = [ | ||
{ | ||
label: 'Home', | ||
icon: 'i-heroicons-home', | ||
to: '/', | ||
}, | ||
] | ||
|
||
if (isLoggedIn.value) { | ||
links.push( | ||
{ | ||
label: 'New blogpost', | ||
icon: 'i-heroicons-newspaper-20-solid', | ||
to: '/new', | ||
}, | ||
{ | ||
label: 'Logout', | ||
icon: 'i-heroicons-newspaper-20-solid', | ||
to: '/auth/logout', | ||
}, | ||
) | ||
} | ||
else { | ||
links.push( | ||
{ | ||
label: 'Register', | ||
icon: 'i-heroicons-key-20-solid', | ||
to: '/auth/signup', | ||
}, | ||
{ | ||
label: 'Login', | ||
icon: 'i-heroicons-lock-open-20-solid', | ||
to: '/auth/login', | ||
}, | ||
{ | ||
label: 'Forgot my password', | ||
icon: 'i-heroicons-sparkles-20-solid', | ||
to: '/auth/forgot-password', | ||
}, | ||
) | ||
} | ||
|
||
return links | ||
}) | ||
</script> | ||
|
||
<template> | ||
<UContainer class="p-8 flex flex-col gap-4"> | ||
<UVerticalNavigation :links="links" /> | ||
|
||
<div> | ||
<NuxtPage /> | ||
</div> | ||
</UContainer> | ||
</template> |
Empty file.
14 changes: 14 additions & 0 deletions
14
packages/create/src/recipes/nuxt/template/components/OAuthProviders.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<template> | ||
<EdgeDbAuthProviders v-slot="{ oAuthProviders: providers }"> | ||
<EdgeDbOAuthButton | ||
v-for="provider of providers" | ||
:key="provider.name" | ||
v-slot="{ redirect }" | ||
:provider="provider.name" | ||
> | ||
<UButton @click="() => redirect()"> | ||
{{ provider.display_name }} | ||
</UButton> | ||
</EdgeDbOAuthButton> | ||
</EdgeDbAuthProviders> | ||
</template> |
38 changes: 38 additions & 0 deletions
38
packages/create/src/recipes/nuxt/template/dbschema/default.esdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using extension auth; | ||
|
||
module default { | ||
global current_user := ( | ||
assert_single(( | ||
select User { id, name } | ||
filter .identity = global ext::auth::ClientTokenIdentity | ||
)) | ||
); | ||
|
||
type User { | ||
required name: str; | ||
required identity: ext::auth::Identity; | ||
multi link posts -> BlogPost { | ||
on source delete delete target; | ||
} | ||
} | ||
|
||
type BlogPost { | ||
property content: str { | ||
default := 'My super blog post.'; | ||
}; | ||
property description: str { | ||
default := 'My blog post description.'; | ||
}; | ||
property title: str { | ||
default := 'My blog super blog post title.'; | ||
}; | ||
required author: User { | ||
default := global current_user; | ||
}; | ||
access policy author_has_full_access | ||
allow all | ||
using (.author ?= global current_user); | ||
access policy others_read_only | ||
allow select; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I think we should have these recipes be starting point for any kind of app, not really an example app, if that makes sense. I'd expect that the schema here is empty, and that we add the auth extension here conditionally based on options set by the user.
To that end, if you want to design a small single page that just scaffolds some very basic layout and styles, definitely do that. Probably something closer to https://github.com/nuxt/starter/tree/v3 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sounds great.
I started doing the "most minimal" Nuxt starter, but for Nuxt it just looks like adding
nuxt-edgedb-module
to their modules array.The rest of it is just described in
nuxt-edgedb-module
.Should I push that instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in getting back to you here.
I'm not sure I understand the question but what I expect to see in these recipes is a totally empty
default.esdl
file, not even including theusing extension auth;
expression even. No migrations, no query builder code generator output, etc. These recipes should represent how you'd start day 0 on a new project, not as an example project, if that makes sense. The UI/app itself should also be minimal so that developers can quickly check that everything is working right, but nothing else.Does that make sense?