This repository was archived by the owner on Feb 11, 2025. It is now read-only.
forked from trpc/trpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into next-merge-2023-12-23--00-16
# Conflicts: # .github/workflows/release.yml # packages/client/src/TRPCClientError.ts # packages/server/src/shared/index.ts # tsconfig.build.json
- Loading branch information
Showing
10 changed files
with
222 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Release next | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
next: | ||
timeout-minutes: 10 | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
|
||
name: Relase @next | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: pnpm/action-setup@v2 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.x | ||
|
||
- name: Check version | ||
run: | | ||
if [[ $(node -p "require('./packages/server/package.json').version.startsWith('10.')") != true ]]; then | ||
echo "Error: The version in packages/server/package.json must start with '10.'" | ||
exit 1 | ||
fi | ||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
run: | | ||
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
key: ${{ runner.os }}-pnpm-store-trpc-${{ github.head_ref }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store-trpc-${{ github.head_ref }}- | ||
- name: Install deps (with cache) | ||
run: pnpm --filter "@trpc/*" --filter root install | ||
|
||
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > $HOME/.npmrc | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- run: pnpm lerna publish --force-publish --canary major --preid alpha-$(pnpm --silent canary-preid) --dist-tag next --yes |
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
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,31 @@ | ||
import { isObject } from '../error/utils'; | ||
|
||
class UnknownCauseError extends Error { | ||
[key: string]: unknown; | ||
} | ||
export function getCauseFromUnknown(cause: unknown): Error | undefined { | ||
if (cause instanceof Error) { | ||
return cause; | ||
} | ||
|
||
const type = typeof cause; | ||
if (type === 'undefined' || type === 'function' || cause === null) { | ||
return undefined; | ||
} | ||
|
||
// Primitive types just get wrapped in an error | ||
if (type !== 'object') { | ||
return new Error(String(cause)); | ||
} | ||
|
||
// If it's an object, we'll create a synthetic error | ||
if (isObject(cause)) { | ||
const err = new UnknownCauseError(); | ||
for (const key in cause) { | ||
err[key] = cause[key]; | ||
} | ||
return err; | ||
} | ||
|
||
return undefined; | ||
} |
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
Oops, something went wrong.