Skip to content

Commit 35e3ec0

Browse files
author
gauravchugh
committed
fix(lit-query): polish package validation and examples
1 parent a87a875 commit 35e3ec0

25 files changed

+761
-100
lines changed

.changeset/lemon-memes-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/lit-query': patch
3+
---
4+
5+
Add initial @tanstack/lit-query package

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ yarn.lock
1010
build
1111
coverage
1212
dist
13+
dist-cjs
1314
dist-ts
15+
packages/lit-query/examples/**/output/playwright/
1416

1517
# misc
1618
.DS_Store

knip.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"entry": ["src/v4/**/*.cjs", "src/v5/**/*.cjs"],
2020
"ignore": ["**/__testfixtures__/**"]
2121
},
22+
"packages/lit-query": {
23+
"ignore": ["examples/**", "src/tests/**"]
24+
},
2225
"packages/vue-query": {
2326
"ignoreDependencies": ["vue2", "vue2.7"]
2427
}

packages/lit-query/examples/lit-query-e2e-app/e2e/lib.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const host = '127.0.0.1'
1212
export const port = DEMO_PORT
1313
export const baseUrl = `http://${host}:${port}`
1414

15-
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
15+
const packageManagerCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
1616
const projectDir = new URL('..', import.meta.url)
1717
const allowExistingServer = process.env.PW_ALLOW_EXISTING_SERVER === 'true'
1818
const strictPortErrorPattern =
@@ -78,7 +78,7 @@ function startServer() {
7878
let startupError
7979

8080
const child = spawn(
81-
npmCommand,
81+
packageManagerCommand,
8282
[
8383
'run',
8484
'dev',

packages/lit-query/examples/lit-query-e2e-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"e2e:refetch-button": "node ./e2e/refetch-button.mjs",
1515
"e2e:lifecycle-reconnect": "node ./e2e/lifecycle-reconnect.mjs",
1616
"e2e:lifecycle-contract": "node ./e2e/lifecycle-contract.mjs",
17-
"e2e:all": "npm run e2e && npm run e2e:query-error && npm run e2e:mutation-error && npm run e2e:refetch-button && npm run e2e:lifecycle-reconnect && npm run e2e:lifecycle-contract",
18-
"e2e:all:headed": "PW_HEADLESS=false npm run e2e:all"
17+
"e2e:all": "pnpm run e2e && pnpm run e2e:query-error && pnpm run e2e:mutation-error && pnpm run e2e:refetch-button && pnpm run e2e:lifecycle-reconnect && pnpm run e2e:lifecycle-contract",
18+
"e2e:all:headed": "PW_HEADLESS=false pnpm run e2e:all"
1919
},
2020
"dependencies": {
2121
"@tanstack/lit-query": "file:../..",

packages/lit-query/examples/lit-query-pagination-app/e2e/lib.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const host = '127.0.0.1'
1212
export const apiUrl = `http://${host}:${API_PORT}`
1313
export const baseUrl = `http://${host}:${DEMO_PORT}`
1414

15-
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
15+
const packageManagerCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
1616
const projectDir = new URL('..', import.meta.url)
1717
const allowExistingServer = process.env.PW_ALLOW_EXISTING_SERVER === 'true'
1818
const strictPortErrorPattern =
@@ -77,7 +77,7 @@ async function captureFailureArtifacts(page, error) {
7777
function startProcess(name, args, extraEnv = {}) {
7878
let startupError
7979

80-
const child = spawn(npmCommand, args, {
80+
const child = spawn(packageManagerCommand, args, {
8181
cwd: projectDir,
8282
env: {
8383
...process.env,

packages/lit-query/examples/lit-query-pagination-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"e2e:error": "node ./e2e/error-recovery.mjs",
1515
"e2e:mutations": "node ./e2e/mutations.mjs",
1616
"e2e:boundary": "node ./e2e/boundary.mjs",
17-
"e2e:all": "npm run e2e && npm run e2e:prefetch && npm run e2e:error && npm run e2e:mutations && npm run e2e:boundary",
18-
"e2e:all:headed": "PW_HEADLESS=false npm run e2e:all"
17+
"e2e:all": "pnpm run e2e && pnpm run e2e:prefetch && pnpm run e2e:error && pnpm run e2e:mutations && pnpm run e2e:boundary",
18+
"e2e:all:headed": "PW_HEADLESS=false pnpm run e2e:all"
1919
},
2020
"dependencies": {
2121
"@tanstack/lit-query": "file:../..",

packages/lit-query/examples/lit-query-pagination-app/scripts/dev.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process'
22
import { once } from 'node:events'
33
import { API_PORT } from '../config/ports.js'
44

5-
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
5+
const packageManagerCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
66
const cwd = new URL('..', import.meta.url)
77

88
function forwardOutput(prefix, stream, output) {
@@ -12,7 +12,7 @@ function forwardOutput(prefix, stream, output) {
1212
}
1313

1414
function start(name, args, extraEnv = {}) {
15-
const child = spawn(npmCommand, args, {
15+
const child = spawn(packageManagerCommand, args, {
1616
cwd,
1717
stdio: ['ignore', 'pipe', 'pipe'],
1818
env: {

packages/lit-query/examples/lit-query-pagination-app/src/api.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,19 @@ async function readJsonOrThrow<T>(
6969
response: Response,
7070
fallbackMessage: string,
7171
): Promise<T> {
72+
if (response.ok) {
73+
return (await response.json()) as T
74+
}
75+
7276
const payload = (await response.json().catch(() => null)) as
7377
| { error?: string }
74-
| T
7578
| null
7679

77-
if (!response.ok) {
78-
throw new Error(
79-
payload && typeof payload === 'object' && 'error' in payload
80-
? String(payload.error ?? fallbackMessage)
81-
: fallbackMessage,
82-
)
83-
}
84-
85-
return payload as T
80+
throw new Error(
81+
payload && typeof payload === 'object' && 'error' in payload
82+
? String(payload.error ?? fallbackMessage)
83+
: fallbackMessage,
84+
)
8685
}
8786

8887
async function requestJson<T>(

packages/lit-query/examples/lit-query-ssr-app/e2e/lib.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { fileURLToPath } from 'node:url'
88
import { chromium } from 'playwright'
99
import { SSR_BASE_URL } from '../config/ports.js'
1010

11-
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
11+
const packageManagerCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
1212
const cwd = resolve(dirname(fileURLToPath(import.meta.url)), '..')
1313
const allowExistingServer = process.env.PW_ALLOW_EXISTING_SERVER === 'true'
1414
const strictPortErrorPattern =
@@ -23,7 +23,7 @@ const selectorTimeoutMs = 10_000
2323
export const baseUrl = SSR_BASE_URL
2424

2525
export function runBuild() {
26-
const result = spawnSync(npmCommand, ['run', 'build'], {
26+
const result = spawnSync(packageManagerCommand, ['run', 'build'], {
2727
cwd,
2828
stdio: 'inherit',
2929
})
@@ -36,7 +36,7 @@ export function runBuild() {
3636
function startServer() {
3737
let startupError
3838

39-
const child = spawn(npmCommand, ['run', 'dev:server'], {
39+
const child = spawn(packageManagerCommand, ['run', 'dev:server'], {
4040
cwd,
4141
env: {
4242
...process.env,

0 commit comments

Comments
 (0)