Skip to content

Commit 9ee944c

Browse files
committed
Merge remote-tracking branch 'origin/main' into alpha
# Conflicts: # .github/workflows/pr.yml
2 parents df4d54d + 1ec2c14 commit 9ee944c

File tree

5 files changed

+77
-61
lines changed

5 files changed

+77
-61
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ jobs:
6363
- name: Install dependencies
6464
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
6565
- run: pnpm run test:format
66-
test-size:
67-
name: 'Size'
66+
test-build:
67+
name: 'Test Build'
6868
runs-on: ubuntu-latest
6969
steps:
7070
- uses: actions/checkout@v3
@@ -77,6 +77,6 @@ jobs:
7777
cache: 'pnpm'
7878
- name: Install dependencies
7979
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
80-
- run: pnpm run test:size
80+
- run: pnpm run test:build
8181
env:
8282
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
"test:format": "pnpm run prettier --check",
1212
"test:lib": "pnpm --filter \"./packages/**\" run test:lib",
1313
"test:lib:dev": "pnpm --filter \"./packages/**\" run test:lib:dev",
14-
"test:size": "pnpm run build && bundlewatch",
14+
"test:build": "pnpm run build && bundlewatch && pnpm run validatePackages",
1515
"test:types": "pnpm --filter \"./packages/**\" run test:types",
1616
"build": "rollup --config rollup.config.js && pnpm --filter \"./packages/**\" run build && pnpm run build:types",
1717
"build:types": "pnpm --filter \"./packages/**\" run build:types",
1818
"watch": "concurrently --kill-others \"rollup --config rollup.config.js -w\" \"pnpm run build:types --watch\"",
1919
"dev": "pnpm run watch",
2020
"prettier": "prettier --plugin-search-dir . \"{packages,examples}/**/src/**/*.{md,js,jsx,ts,tsx,json,vue,svelte}\"",
2121
"prettier:write": "pnpm run prettier --write",
22-
"cipublish": "ts-node scripts/publish.ts"
22+
"cipublish": "ts-node scripts/publish.ts",
23+
"validatePackages": "ts-node scripts/validate-packages.ts"
2324
},
2425
"namespace": "@tanstack",
2526
"devDependencies": {

packages/solid-query/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"test:eslint": "eslint --ext .ts,.tsx ./src",
3434
"test:types": "tsc",
3535
"test:lib": "jest --config ./jest.config.ts",
36-
"test:lib:dev": "pnpm run test:lib --watch"
36+
"test:lib:dev": "pnpm run test:lib --watch",
37+
"build:types": "tsc --build"
3738
},
3839
"files": [
3940
"build/lib/*",

scripts/publish.ts

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import {
2-
branchConfigs,
3-
examplesDirs,
4-
latestBranch,
5-
packages,
6-
rootDir,
7-
} from './config'
1+
import { branchConfigs, latestBranch, packages, rootDir } from './config'
82
import type { BranchConfig, Commit, Package } from './types'
93

104
// Originally ported to TS from https://github.com/remix-run/react-router/tree/main/scripts/{version,publish}.js
115
import path from 'path'
12-
import { exec, execSync } from 'child_process'
6+
import { execSync } from 'child_process'
137
import fsp from 'fs/promises'
148
import chalk from 'chalk'
159
import jsonfile from 'jsonfile'
@@ -373,53 +367,7 @@ async function run() {
373367
console.info('')
374368

375369
console.info('Validating packages...')
376-
const failedValidations: string[] = []
377-
378-
await Promise.all(
379-
packages.map(async (pkg) => {
380-
const pkgJson = await readPackageJson(
381-
path.resolve(rootDir, 'packages', pkg.packageDir, 'package.json'),
382-
)
383-
384-
const entries =
385-
pkg.name === '@tanstack/eslint-plugin-query'
386-
? (['main'] as const)
387-
: pkg.name === '@tanstack/svelte-query'
388-
? (['types', 'module'] as const)
389-
: (['main', 'types', 'module'] as const)
390-
391-
await Promise.all(
392-
entries.map(async (entryKey) => {
393-
const entry = pkgJson[entryKey] as string
394-
395-
if (!entry) {
396-
throw new Error(
397-
`Missing entry for "${entryKey}" in ${pkg.packageDir}/package.json!`,
398-
)
399-
}
400-
401-
const filePath = path.resolve(
402-
rootDir,
403-
'packages',
404-
pkg.packageDir,
405-
entry,
406-
)
407-
408-
try {
409-
await fsp.access(filePath)
410-
} catch (err) {
411-
failedValidations.push(`Missing build file: ${filePath}`)
412-
}
413-
}),
414-
)
415-
}),
416-
)
417-
console.info('')
418-
if (failedValidations.length > 0) {
419-
throw new Error(
420-
'Some packages failed validation:\n\n' + failedValidations.join('\n'),
421-
)
422-
}
370+
execSync(`pnpm run validatePackages`, { encoding: 'utf8', stdio: 'inherit' })
423371

424372
console.info(`Updating all changed packages to version ${version}...`)
425373
// Update each package to the new version

scripts/validate-packages.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { packages, rootDir } from './config'
2+
import path from 'path'
3+
import fsp from 'fs/promises'
4+
import jsonfile from 'jsonfile'
5+
6+
import type { PackageJson } from 'type-fest'
7+
8+
async function run() {
9+
console.info('Validating packages...')
10+
const failedValidations: string[] = []
11+
12+
await Promise.all(
13+
packages.map(async (pkg) => {
14+
const pkgJson = await readPackageJson(
15+
path.resolve(rootDir, 'packages', pkg.packageDir, 'package.json'),
16+
)
17+
18+
const entries =
19+
pkg.name === '@tanstack/eslint-plugin-query'
20+
? (['main'] as const)
21+
: pkg.name === '@tanstack/svelte-query'
22+
? (['types', 'module'] as const)
23+
: (['main', 'types', 'module'] as const)
24+
25+
await Promise.all(
26+
entries.map(async (entryKey) => {
27+
const entry = pkgJson[entryKey] as string
28+
29+
if (!entry) {
30+
throw new Error(
31+
`Missing entry for "${entryKey}" in ${pkg.packageDir}/package.json!`,
32+
)
33+
}
34+
35+
const filePath = path.resolve(
36+
rootDir,
37+
'packages',
38+
pkg.packageDir,
39+
entry,
40+
)
41+
42+
try {
43+
await fsp.access(filePath)
44+
} catch (err) {
45+
failedValidations.push(`Missing build file: ${filePath}`)
46+
}
47+
}),
48+
)
49+
}),
50+
)
51+
console.info('')
52+
if (failedValidations.length > 0) {
53+
throw new Error(
54+
'Some packages failed validation:\n\n' + failedValidations.join('\n'),
55+
)
56+
}
57+
}
58+
59+
run().catch((err) => {
60+
console.info(err)
61+
process.exit(1)
62+
})
63+
64+
async function readPackageJson(pathName: string) {
65+
return (await jsonfile.readFile(pathName)) as PackageJson
66+
}

0 commit comments

Comments
 (0)