@nerd-bible/valio 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +6 -1
- package/.github/workflows/publish.yml +0 -25
- package/publish.sh +0 -23
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# valio
|
|
2
2
|
|
|
3
|
-
Encode and decode
|
|
3
|
+
Encode and decode Typescript types with extensible error handling.
|
|
4
4
|
|
|
5
5
|
## Why?
|
|
6
6
|
|
|
7
7
|
I like [Zod](https://zod.dev), but its codecs don't support
|
|
8
|
-
[custom error contexts.](https://github.com/colinhacks/zod/issues/)
|
|
8
|
+
[custom error contexts.](https://github.com/colinhacks/zod/issues/) I tried
|
|
9
|
+
adding support to Zod but found it easier to start from scratch.
|
|
9
10
|
|
|
10
11
|
## Theory
|
|
11
12
|
|
|
@@ -54,6 +55,7 @@ expect(schema.encode(3)).toEqual({
|
|
|
54
55
|
```
|
|
55
56
|
|
|
56
57
|
There are common builtin codecs for coercion.
|
|
58
|
+
|
|
57
59
|
```ts
|
|
58
60
|
import * as v from "@nerd-bible/valio";
|
|
59
61
|
|
|
@@ -121,5 +123,3 @@ expect(schema.decode(3, new MyContext())).toEqual({
|
|
|
121
123
|
errors: { ".": [{ input: 3, message: "You done messed up" }] },
|
|
122
124
|
});
|
|
123
125
|
```
|
|
124
|
-
|
|
125
|
-
Those are the highlights. Read the `.test.ts` files for the rest.
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Publish Package
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
tags:
|
|
5
|
-
- v*
|
|
6
|
-
branches:
|
|
7
|
-
- master
|
|
8
|
-
permissions:
|
|
9
|
-
id-token: write # npm OIDC
|
|
10
|
-
contents: write # push tags
|
|
11
|
-
jobs:
|
|
12
|
-
publish:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- name: Print GitHub event action
|
|
16
|
-
run: echo "${{ github.event_name }}"
|
|
17
|
-
- uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
fetch-depth: 0 # whole history needed for potential tag bump
|
|
20
|
-
- uses: oven-sh/setup-bun@v2
|
|
21
|
-
- run: bun ci
|
|
22
|
-
- run: bun run build
|
|
23
|
-
- run: bun test
|
|
24
|
-
- run: bun run fmt
|
|
25
|
-
- run: ./publish.sh
|
package/publish.sh
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
TAG_CMD="git describe --tags --abbrev=0 --match=v[0-9]*.[0-9]*.[0-9]*"
|
|
5
|
-
|
|
6
|
-
git fetch --tags
|
|
7
|
-
VERSION=$($TAG_CMD --exact-match 2>/dev/null || true)
|
|
8
|
-
# is the latest commit missing a version tag?
|
|
9
|
-
if [[ -z $VERSION ]]; then
|
|
10
|
-
VERSION=$($TAG_CMD 2>/dev/null || echo 'v0.0.0')
|
|
11
|
-
echo "No manual tag, bumping $VERSION"
|
|
12
|
-
VERSION=$(echo $VERSION | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
|
13
|
-
git tag $VERSION
|
|
14
|
-
git push --tags origin master
|
|
15
|
-
fi
|
|
16
|
-
echo "Publishing $VERSION"
|
|
17
|
-
JIT_JSON=$(cat package.json | jq "
|
|
18
|
-
.version = \"${VERSION:1}\" |
|
|
19
|
-
.repository.url = \"git+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY\"
|
|
20
|
-
")
|
|
21
|
-
echo -E "$JIT_JSON" > package.json
|
|
22
|
-
|
|
23
|
-
bunx npm@latest publish
|