Skip to content

Commit

Permalink
rename svelte script option
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryB432 committed Sep 1, 2024
1 parent ee3b249 commit f56d772
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion e2e/svelte-e2e/tests/svelte.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('svelte e2e', () => {
`generate @gb-nx/svelte:application --projectPath=subdir/${project} --skipFormat --no-interactive --verbose`
);
await runNxCommandAsync(
`generate @gb-nx/svelte:route a/b/c --runes --load=shared -p=${project} --skipFormat --no-interactive`
`generate @gb-nx/svelte:route a/b/c --runes --load=universal -p=${project} --skipFormat --no-interactive`
);
expect(() =>
checkFilesExist(
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/generators/route/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('route generator', () => {
await skipFormatGenerator(appTree, {
name: 'some-route',
language: 'ts',
load: 'shared',
load: 'universal',
project: 'test',
});
expect(appTree.children('apps/test/src/routes/some-route')).toEqual([
Expand Down
8 changes: 4 additions & 4 deletions packages/svelte/src/generators/route/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function addLoadPage(
tree.write(fname, options.language === 'ts' ? ts : js);
break;
}
case 'shared': {
case 'universal': {
const fname = joinPathFragments(
proj.root,
locations.routes,
Expand Down Expand Up @@ -156,7 +156,7 @@ function addSveltePage(

const scriptsRecord: Record<
string,
{ none: string; server: string; shared: string }
{ none: string; server: string; universal: string }
> = {
js: {
none: `<script>
Expand All @@ -170,7 +170,7 @@ function addSveltePage(
/** @type {import('./$types').PageData} */
${options.runes ? 'let { data } = $props()' : 'export let data'};
</script>`,
shared: `<script>
universal: `<script>
/** @type {import('./$types').PageData} */
${options.runes ? 'let { data } = $props()' : 'export let data'};
</script>`,
Expand All @@ -191,7 +191,7 @@ function addSveltePage(
: 'export let data: PageData'
};
</script>`,
shared: `<script lang="ts">
universal: `<script lang="ts">
import type { PageData } from './$types';
${
options.runes
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/generators/route/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export interface Schema {
*/
style?: 'css' | 'scss';
/**
* Source of data for your load function
* Should the load function run on client and server (universal) or just server
*/
load?: 'shared' | 'server' | 'none';
load?: 'universal' | 'server' | 'none';
/**
* Use svelte runes (requires svelte >=5)
*/
Expand Down
8 changes: 6 additions & 2 deletions packages/svelte/src/generators/route/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"command": "nx g @gb-nx/svelte:route myroute --project myapp --language scss",
"description": "Generate a route in the myapp Svelte Kit package"
},
{
"command": "nx g @gb-nx/svelte:route myroute --project myapp --load universal",
"description": "Generate a route with a load function to run on both client and server"
}
],
"type": "object",
Expand Down Expand Up @@ -56,9 +60,9 @@
"default": "css"
},
"load": {
"description": "Source of data for your load function",
"description": "Should the load function run on client and server (universal) or just server",
"type": "string",
"enum": ["shared", "server", "none"],
"enum": ["universal", "server", "none"],
"default": "none"
},
"runes": {
Expand Down

0 comments on commit f56d772

Please sign in to comment.