-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update packages, including trpc-svelte-query
- Loading branch information
Showing
19 changed files
with
121 additions
and
98 deletions.
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
15 changes: 0 additions & 15 deletions
15
template_builder/templates/extras/src/lib/server/{Trpc,Edge}context.ts
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
template_builder/templates/extras/src/lib/server/{Trpc}context.ts
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
9 changes: 9 additions & 0 deletions
9
template_builder/templates/extras/src/lib/server/{Trpc}server.ts
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,9 @@ | ||
import { createTRPCSvelteServer } from 'trpc-svelte-query/server'; | ||
import { appRouter } from './routes/_app'; | ||
import { createContext } from './context'; | ||
|
||
export const trpcServer = createTRPCSvelteServer({ | ||
endpoint: '/api/trpc', | ||
router: appRouter, | ||
createContext, | ||
}); |
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
18 changes: 9 additions & 9 deletions
18
template_builder/templates/extras/src/lib/trpc/{Trpc}transformer.ts
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { parse, stringify } from 'devalue'; | ||
import { parse, stringify, uneval } from 'devalue'; | ||
|
||
export const transformer = { | ||
// input: { | ||
serialize: (object: unknown) => stringify(object), | ||
deserialize: (object: string) => parse(object), | ||
// }, | ||
// output: { | ||
// serialize: (object: unknown) => uneval(object), | ||
// deserialize: (object: string) => (0, eval)(`(${object})`), | ||
// }, | ||
input: { | ||
serialize: (object: unknown) => stringify(object), | ||
deserialize: (object: string) => parse(object), | ||
}, | ||
output: { | ||
serialize: (object: unknown) => uneval(object), | ||
deserialize: (object: string) => (0, eval)(`(${object})`), | ||
}, | ||
}; |
16 changes: 0 additions & 16 deletions
16
template_builder/templates/extras/src/routes/api/trpc/[...trpc]/{Trpc,Edge}+server.ts
This file was deleted.
Oops, something went wrong.
18 changes: 3 additions & 15 deletions
18
template_builder/templates/extras/src/routes/api/trpc/[...trpc]/{Trpc}+server.ts
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 |
---|---|---|
@@ -1,16 +1,4 @@ | ||
import { appRouter } from '$lib/server/routes/_app'; | ||
import { createContext } from '$lib/server/context'; | ||
import { fetchRequestHandler } from '@trpc/server/adapters/fetch'; | ||
import type { RequestHandler } from './$types'; | ||
import { trpcServer } from '$lib/server/server'; | ||
|
||
const handler: RequestHandler = async (event) => { | ||
return fetchRequestHandler({ | ||
endpoint: '/api/trpc', | ||
req: event.request, | ||
router: appRouter, | ||
createContext, | ||
}); | ||
}; | ||
|
||
export const GET = handler; | ||
export const POST = handler; | ||
export const GET = trpcServer.handler; | ||
export const POST = trpcServer.handler; |
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
4 changes: 2 additions & 2 deletions
4
template_builder/templates/extras/src/routes/{Trpc}+layout.server.ts
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { trpc } from '$lib/trpc'; | ||
import { trpcServer } from '$lib/server/server'; | ||
import type { LayoutServerLoad } from './$types'; | ||
|
||
export const load: LayoutServerLoad = async (event) => { | ||
return { | ||
trpc: trpc.ssr(event), | ||
trpc: trpcServer.hydrateToClient(event), | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20230115.0", | ||
"@sveltejs/adapter-cloudflare": "^2.0.1", | ||
"@cloudflare/workers-types": "^4.20230511.0", | ||
"@sveltejs/adapter-cloudflare": "^2.2.4", | ||
"@sveltejs/adapter-auto": null | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"devDependencies": { | ||
"autoprefixer": "^10.4.13", | ||
"postcss": "^8.4.21", | ||
"autoprefixer": "^10.4.14", | ||
"postcss": "^8.4.23", | ||
"postcss-load-config": "^4.0.1", | ||
"prettier-plugin-tailwindcss": "^0.2.2", | ||
"tailwindcss": "^3.2.4" | ||
"prettier-plugin-tailwindcss": "^0.3.0", | ||
"tailwindcss": "^3.3.2" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"dependencies": { | ||
"@tanstack/svelte-query": "^4.24.4", | ||
"@trpc/client": "^10.9.1", | ||
"@trpc/server": "^10.9.1", | ||
"devalue": "^4.2.3", | ||
"trpc-svelte-query": "^0.0.2", | ||
"zod": "^3.20.2" | ||
"@tanstack/svelte-query": "^4.29.7", | ||
"@trpc/client": "^10.27.0", | ||
"@trpc/server": "^10.27.0", | ||
"devalue": "^4.3.1", | ||
"trpc-svelte-query": "1.0.0", | ||
"zod": "^3.21.4" | ||
} | ||
} |
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 @@ | ||
import { resolve, basename } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { readdir, readFile } from 'node:fs/promises'; | ||
|
||
const root = resolve(fileURLToPath(import.meta.url), '../template_builder/templates'); | ||
|
||
const dependencies = new Map(); | ||
|
||
for await (const f of getFiles(root)) { | ||
if (!/^(\{[^{}]*\})?package\.json$/.test(basename(f))) continue; | ||
const pkg = JSON.parse(await readFile(f, 'utf8')); | ||
const entries = [ | ||
...Object.entries(pkg.dependencies || {}), | ||
...Object.entries(pkg.devDependencies || {}) | ||
]; | ||
for (const [name, version] of entries) { | ||
if (version === null) continue; | ||
dependencies.set(name, [version, basename(f)]); | ||
} | ||
} | ||
|
||
const neededUpgrades = new Map(); | ||
|
||
for (const [name, [version, file]] of dependencies) { | ||
const latest = await latestVersion(name); | ||
if (!latest) continue; | ||
if (latest !== version.replace(/^[\^~]/, '')) { | ||
if (!neededUpgrades.has(file)) neededUpgrades.set(file, []); | ||
neededUpgrades.get(file).push([name, version, latest]); | ||
} | ||
} | ||
|
||
for (const [file, upgrades] of neededUpgrades) { | ||
console.log('\n' + file); | ||
for (const [name, version, latest] of upgrades) { | ||
console.log(` ${name}: ${version} -> ${latest}`); | ||
} | ||
} | ||
|
||
async function latestVersion(packageName) { | ||
const url = new URL(encodeURIComponent(packageName).replace(/^%40/, '@'), 'https://registry.npmjs.org/'); | ||
const res = await fetch(url, { | ||
headers: { accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' } | ||
}); | ||
const data = await res.json(); | ||
return data?.['dist-tags']?.latest; | ||
} | ||
|
||
async function* getFiles(dir) { | ||
const dirents = await readdir(dir, { withFileTypes: true }); | ||
for (const dirent of dirents) { | ||
const res = resolve(dir, dirent.name); | ||
if (dirent.isDirectory()) { | ||
yield* getFiles(res); | ||
} else { | ||
yield res; | ||
} | ||
} | ||
} |