@sablier/devkit 1.5.0 → 1.6.0
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 +136 -17
- package/just/base.just +29 -26
- package/just/evm.just +1 -2
- package/just/npm.just +1 -2
- package/just/tsv.just +2 -4
- package/package.json +21 -6
- package/tsconfig/base.json +1 -0
- package/tsconfig/build.json +1 -0
- package/tsconfig/next.json +0 -1
- package/vitest/index.ts +29 -0
package/README.md
CHANGED
|
@@ -1,33 +1,152 @@
|
|
|
1
1
|
# 🛠️ Sablier Devkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.npmjs.com/package/@sablier/devkit)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Configuration files and reusable scripts for Sablier repositories. Designed to be extended and customized as needed.
|
|
6
7
|
|
|
7
|
-
##
|
|
8
|
+
## 📦 Installation
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
```bash
|
|
11
|
+
npm install @sablier/devkit
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or with other package managers:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @sablier/devkit
|
|
18
|
+
bun add @sablier/devkit
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 🚀 Usage
|
|
22
|
+
|
|
23
|
+
### Biome
|
|
24
|
+
|
|
25
|
+
Extend the base Biome configuration in your `biome.jsonc`:
|
|
26
|
+
|
|
27
|
+
```jsonc
|
|
28
|
+
{
|
|
29
|
+
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
|
|
30
|
+
"extends": ["@sablier/devkit/biome"],
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For UI projects, use the UI variant:
|
|
35
|
+
|
|
36
|
+
```jsonc
|
|
37
|
+
{
|
|
38
|
+
"extends": ["@sablier/devkit/biome/ui"],
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Prettier
|
|
43
|
+
|
|
44
|
+
Reference the Prettier config in your `package.json`:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"prettier": "@sablier/devkit/prettier"
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### TypeScript
|
|
53
|
+
|
|
54
|
+
Extend TSConfig presets in your `tsconfig.json`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"extends": "@sablier/devkit/tsconfig/base"
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Available presets:
|
|
63
|
+
|
|
64
|
+
- `@sablier/devkit/tsconfig/base` — Base TypeScript configuration
|
|
65
|
+
- `@sablier/devkit/tsconfig/build` — Build-optimized configuration
|
|
66
|
+
- `@sablier/devkit/tsconfig/next` — Next.js configuration
|
|
67
|
+
|
|
68
|
+
### Vitest
|
|
69
|
+
|
|
70
|
+
Use the devkit vitest config factory in your `vitest.config.ts`:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { defineDevkitConfig } from "@sablier/devkit/vitest";
|
|
74
|
+
|
|
75
|
+
export default defineDevkitConfig({
|
|
76
|
+
environment: "jsdom", // or "node" (default), "happy-dom"
|
|
77
|
+
setupFiles: ["./tests/setup.ts"],
|
|
78
|
+
coverage: true,
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The config provides CI-aware defaults:
|
|
83
|
+
|
|
84
|
+
- `globals: true`
|
|
85
|
+
- `retry: 2` in CI, `0` locally
|
|
86
|
+
- `testTimeout: 30s` in CI, `10s` locally
|
|
87
|
+
- `reporters: ["basic"]` in CI, `["verbose"]` locally
|
|
88
|
+
|
|
89
|
+
For merging with existing Vite configs:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { defineDevkitConfig, mergeConfig } from "@sablier/devkit/vitest";
|
|
93
|
+
import { defineConfig } from "vitest/config";
|
|
94
|
+
|
|
95
|
+
export default mergeConfig(
|
|
96
|
+
defineDevkitConfig({ environment: "jsdom" }),
|
|
97
|
+
defineConfig({
|
|
98
|
+
test: {
|
|
99
|
+
alias: { "@": "./src" },
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Just
|
|
106
|
+
|
|
107
|
+
Import Just recipes in your `justfile`:
|
|
108
|
+
|
|
109
|
+
```just
|
|
110
|
+
import "@sablier/devkit/just/base.just"
|
|
111
|
+
import "@sablier/devkit/just/npm.just"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Available modules:
|
|
115
|
+
|
|
116
|
+
| Module | Description |
|
|
117
|
+
| --------------- | ------------------------------- |
|
|
118
|
+
| `base.just` | Common development recipes |
|
|
119
|
+
| `npm.just` | NPM package management |
|
|
120
|
+
| `evm.just` | EVM/Foundry tooling |
|
|
121
|
+
| `tsv.just` | TypeScript validation |
|
|
122
|
+
| `settings.just` | Just settings and configuration |
|
|
123
|
+
|
|
124
|
+
## ⚙️ Available Configs
|
|
125
|
+
|
|
126
|
+
| Tool | Config File/Directory |
|
|
127
|
+
| --------------- | ---------------------------------------- |
|
|
128
|
+
| 🔍 Biome | [`biome/`](./biome/) |
|
|
129
|
+
| 📝 EditorConfig | [`.editorconfig`](./.editorconfig) |
|
|
130
|
+
| 🛠 Just | [`just/`](./just/) |
|
|
131
|
+
| ✨ Prettier | [`.prettierrc.json`](./.prettierrc.json) |
|
|
132
|
+
| 📦 TSConfig | [`tsconfig/`](./tsconfig/) |
|
|
133
|
+
| 🧪 Vitest | [`vitest/`](./vitest/) |
|
|
16
134
|
|
|
17
135
|
## 🐈⬛ GitHub Actions
|
|
18
136
|
|
|
19
|
-
The [setup](./actions/setup/)
|
|
20
|
-
workflow.
|
|
137
|
+
The [setup](./actions/setup/) action installs requisite dependencies in GitHub CI workflows.
|
|
21
138
|
|
|
22
|
-
|
|
139
|
+
```yaml
|
|
140
|
+
- uses: sablier-labs/devkit/actions/setup@main
|
|
141
|
+
```
|
|
23
142
|
|
|
24
|
-
|
|
143
|
+
## 🖥️ Setup Script
|
|
25
144
|
|
|
26
|
-
|
|
145
|
+
For Sablier Labs employees and staff, see [`shell/setup.sh`](./shell/setup.sh).
|
|
27
146
|
|
|
28
|
-
##
|
|
147
|
+
## 🤝 Contributing
|
|
29
148
|
|
|
30
|
-
|
|
149
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
31
150
|
|
|
32
151
|
## 📄 License
|
|
33
152
|
|
package/just/base.just
CHANGED
|
@@ -28,9 +28,8 @@ _clean +globs:
|
|
|
28
28
|
nlx del-cli "{{ globs }}"
|
|
29
29
|
|
|
30
30
|
# Clear node_modules recursively
|
|
31
|
-
[confirm("Are you sure you want to delete all node_modules, including in subdirectories? Y/n")]
|
|
32
|
-
|
|
33
|
-
clean-modules +globs="node_modules **/node_modules":
|
|
31
|
+
[confirm("Are you sure you want to delete all node_modules, including in subdirectories? Y/n"), no-cd]
|
|
32
|
+
clean-modules +globs="**/node_modules":
|
|
34
33
|
nlx del-cli {{ globs }}
|
|
35
34
|
|
|
36
35
|
# Install the Node.js dependencies; run with --frozen to install the dependencies with the frozen lockfile
|
|
@@ -49,31 +48,27 @@ alias tb := tsc-build
|
|
|
49
48
|
# ---------------------------------------------------------------------------- #
|
|
50
49
|
|
|
51
50
|
# Check code with Biome - runs both the checker and the linter
|
|
52
|
-
[group("checks")]
|
|
53
|
-
[no-cd]
|
|
51
|
+
[group("checks"), no-cd]
|
|
54
52
|
@biome-check +globs=".":
|
|
55
53
|
na biome check {{ globs }}
|
|
56
54
|
alias bc := biome-check
|
|
57
55
|
|
|
58
56
|
# Lint code with Biome
|
|
59
|
-
[group("checks")]
|
|
60
|
-
[no-cd]
|
|
57
|
+
[group("checks"), no-cd]
|
|
61
58
|
@biome-lint +globs=".":
|
|
62
59
|
na biome lint {{ globs }}
|
|
63
60
|
alias bl := biome-lint
|
|
64
61
|
|
|
65
62
|
# Fix code with Biome
|
|
66
63
|
# The `noUnusedImports` rule is disabled by default to allow unused imports during development
|
|
67
|
-
[group("checks")]
|
|
68
|
-
[no-cd]
|
|
64
|
+
[group("checks"), no-cd]
|
|
69
65
|
@biome-write +globs=".":
|
|
70
66
|
na biome check --write {{ globs }}
|
|
71
67
|
na biome lint --unsafe --write --only correctness/noUnusedImports {{ globs }}
|
|
72
68
|
alias bw := biome-write
|
|
73
69
|
|
|
74
70
|
# Run all code checks
|
|
75
|
-
[group("checks")]
|
|
76
|
-
[no-cd]
|
|
71
|
+
[group("checks"), no-cd]
|
|
77
72
|
@full-check:
|
|
78
73
|
just _run-with-status biome-check
|
|
79
74
|
just _run-with-status prettier-check
|
|
@@ -83,8 +78,7 @@ alias bw := biome-write
|
|
|
83
78
|
alias fc := full-check
|
|
84
79
|
|
|
85
80
|
# Run all code fixes
|
|
86
|
-
[group("checks")]
|
|
87
|
-
[no-cd]
|
|
81
|
+
[group("checks"), no-cd]
|
|
88
82
|
@full-write:
|
|
89
83
|
just _run-with-status biome-write
|
|
90
84
|
just _run-with-status prettier-write
|
|
@@ -93,37 +87,41 @@ alias fc := full-check
|
|
|
93
87
|
alias fw := full-write
|
|
94
88
|
|
|
95
89
|
# Run knip checks
|
|
96
|
-
[group("checks")]
|
|
97
|
-
[no-cd]
|
|
90
|
+
[group("checks"), no-cd]
|
|
98
91
|
@knip-check:
|
|
99
92
|
na knip
|
|
100
93
|
alias kc := knip-check
|
|
101
94
|
|
|
102
95
|
# Run knip fix
|
|
103
|
-
[group("checks")]
|
|
104
|
-
[no-cd]
|
|
96
|
+
[group("checks"), no-cd]
|
|
105
97
|
@knip-write:
|
|
106
98
|
na knip --fix
|
|
107
99
|
alias kw := knip-write
|
|
108
100
|
|
|
109
101
|
# Check Prettier formatting
|
|
110
|
-
[group("checks")]
|
|
111
|
-
[no-cd]
|
|
102
|
+
[group("checks"), no-cd]
|
|
112
103
|
@prettier-check +globs=GLOBS_PRETTIER:
|
|
113
|
-
na prettier
|
|
104
|
+
na prettier \
|
|
105
|
+
--check \
|
|
106
|
+
--cache \
|
|
107
|
+
--log-level warn \
|
|
108
|
+
--no-error-on-unmatched-pattern \
|
|
109
|
+
{{ globs }}
|
|
114
110
|
alias pc := prettier-check
|
|
115
111
|
|
|
116
112
|
# Format using Prettier
|
|
117
|
-
[group("checks")]
|
|
118
|
-
[no-cd]
|
|
113
|
+
[group("checks"), no-cd]
|
|
119
114
|
@prettier-write +globs=GLOBS_PRETTIER:
|
|
120
|
-
na prettier
|
|
115
|
+
na prettier \
|
|
116
|
+
--write \
|
|
117
|
+
--cache \
|
|
118
|
+
--log-level warn \
|
|
119
|
+
--no-error-on-unmatched-pattern \
|
|
120
|
+
{{ globs }}
|
|
121
121
|
alias pw := prettier-write
|
|
122
122
|
|
|
123
123
|
# Type check with TypeScript (tsgo default, falls back to tsc if unavailable)
|
|
124
|
-
[group("checks")]
|
|
125
|
-
[no-cd]
|
|
126
|
-
[script("bash")]
|
|
124
|
+
[group("checks"), no-cd, script("bash")]
|
|
127
125
|
type-check compiler="tsgo" project="tsconfig.json":
|
|
128
126
|
cmd="{{ compiler }}"
|
|
129
127
|
if [[ "$cmd" == "tsgo" ]] && [[ ! -x "node_modules/.bin/tsgo" ]]; then
|
|
@@ -133,6 +131,10 @@ type-check compiler="tsgo" project="tsconfig.json":
|
|
|
133
131
|
alias tc := type-check
|
|
134
132
|
alias tsc-check := type-check
|
|
135
133
|
|
|
134
|
+
# ---------------------------------------------------------------------------- #
|
|
135
|
+
# UTILITIES #
|
|
136
|
+
# ---------------------------------------------------------------------------- #
|
|
137
|
+
|
|
136
138
|
# Private recipe to run a check with formatted output
|
|
137
139
|
[no-cd]
|
|
138
140
|
@_run-with-status recipe *args:
|
|
@@ -141,3 +143,4 @@ alias tsc-check := type-check
|
|
|
141
143
|
just {{ recipe }} {{ args }}
|
|
142
144
|
echo '{{ GREEN }}✓ {{ recipe }} completed{{ NORMAL }}'
|
|
143
145
|
alias rws := _run-with-status
|
|
146
|
+
alias _rws := _run-with-status
|
package/just/evm.just
CHANGED
|
@@ -115,8 +115,7 @@ build-optimized *args:
|
|
|
115
115
|
forge build --extra-output-files metadata {{ args }}
|
|
116
116
|
|
|
117
117
|
# Dump code coverage to an html file
|
|
118
|
-
[group("foundry")]
|
|
119
|
-
[script]
|
|
118
|
+
[group("foundry"), script("bash")]
|
|
120
119
|
coverage:
|
|
121
120
|
if ! command -v genhtml >/dev/null 2>&1; then
|
|
122
121
|
echo "✗ genhtml CLI not found"
|
package/just/npm.just
CHANGED
|
@@ -38,8 +38,7 @@ tag *version:
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
# Check that package.json version includes -beta.x suffix
|
|
41
|
-
[private]
|
|
42
|
-
[script]
|
|
41
|
+
[private, script("bash")]
|
|
43
42
|
@check-beta-version:
|
|
44
43
|
# Extract version from package.json using jq for reliable JSON parsing
|
|
45
44
|
version=$(jq -r '.version' package.json)
|
package/just/tsv.just
CHANGED
|
@@ -5,8 +5,7 @@ import "./settings.just"
|
|
|
5
5
|
# ---------------------------------------------------------------------------- #
|
|
6
6
|
|
|
7
7
|
# Check TSV files using qsv: https://github.com/dathere/qsv
|
|
8
|
-
[group("checks")]
|
|
9
|
-
[script]
|
|
8
|
+
[group("checks"), script("bash")]
|
|
10
9
|
_tsv-check globs="data/*/*.tsv" schema="" ignore="*.tsv.invalid|*.tsv.valid|*validation-errors.tsv":
|
|
11
10
|
if ! command -v qsv >/dev/null 2>&1; then
|
|
12
11
|
echo "✗ qsv CLI not found"
|
|
@@ -43,8 +42,7 @@ _tsv-check globs="data/*/*.tsv" schema="" ignore="*.tsv.invalid|*.tsv.valid|*val
|
|
|
43
42
|
fi
|
|
44
43
|
|
|
45
44
|
# Show validation errors for a TSV file
|
|
46
|
-
[group("checks")]
|
|
47
|
-
[script]
|
|
45
|
+
[group("checks"), script("bash")]
|
|
48
46
|
_tsv-show-errors file:
|
|
49
47
|
error_file="{{ file }}.validation-errors.tsv"
|
|
50
48
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Configuration files and reusable scripts for Sablier repositories",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.6.0",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Sablier Labs Ltd",
|
|
9
9
|
"url": "https://sablier.com"
|
|
@@ -13,7 +13,16 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@biomejs/biome": "^2.3.7",
|
|
16
|
-
"prettier": "^3.6.2"
|
|
16
|
+
"prettier": "^3.6.2",
|
|
17
|
+
"vitest": "^3.2.0"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"vitest": ">=2.0.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependenciesMeta": {
|
|
23
|
+
"vitest": {
|
|
24
|
+
"optional": true
|
|
25
|
+
}
|
|
17
26
|
},
|
|
18
27
|
"exports": {
|
|
19
28
|
"./biome": "./biome/base.jsonc",
|
|
@@ -21,16 +30,21 @@
|
|
|
21
30
|
"./prettier": "./.prettierrc.json",
|
|
22
31
|
"./tsconfig/base": "./tsconfig/base.json",
|
|
23
32
|
"./tsconfig/build": "./tsconfig/build.json",
|
|
24
|
-
"./tsconfig/next": "./tsconfig/next.json"
|
|
33
|
+
"./tsconfig/next": "./tsconfig/next.json",
|
|
34
|
+
"./vitest": {
|
|
35
|
+
"import": "./vitest/index.js",
|
|
36
|
+
"types": "./vitest/index.d.ts"
|
|
37
|
+
}
|
|
25
38
|
},
|
|
26
39
|
"engines": {
|
|
27
40
|
"node": ">=20"
|
|
28
41
|
},
|
|
29
42
|
"files": [
|
|
30
43
|
"biome/",
|
|
31
|
-
".prettierrc.json",
|
|
32
44
|
"just/",
|
|
33
|
-
"
|
|
45
|
+
".prettierrc.json",
|
|
46
|
+
"tsconfig/",
|
|
47
|
+
"vitest/"
|
|
34
48
|
],
|
|
35
49
|
"keywords": [
|
|
36
50
|
"biome",
|
|
@@ -39,7 +53,8 @@
|
|
|
39
53
|
"prettier",
|
|
40
54
|
"sablier",
|
|
41
55
|
"tsconfig",
|
|
42
|
-
"typescript"
|
|
56
|
+
"typescript",
|
|
57
|
+
"vitest"
|
|
43
58
|
],
|
|
44
59
|
"publishConfig": {
|
|
45
60
|
"access": "public"
|
package/tsconfig/base.json
CHANGED
package/tsconfig/build.json
CHANGED
package/tsconfig/next.json
CHANGED
package/vitest/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { UserConfig } from "vitest/config";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export interface DevkitVitestOptions {
|
|
5
|
+
environment?: "node" | "jsdom" | "happy-dom";
|
|
6
|
+
setupFiles?: string[];
|
|
7
|
+
coverage?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function defineDevkitConfig(options: DevkitVitestOptions = {}) {
|
|
11
|
+
const isCI = !!process.env.CI;
|
|
12
|
+
|
|
13
|
+
const baseConfig: UserConfig = {
|
|
14
|
+
test: {
|
|
15
|
+
coverage: options.coverage ? { provider: "v8" } : undefined,
|
|
16
|
+
environment: options.environment ?? "node",
|
|
17
|
+
globals: true,
|
|
18
|
+
reporters: isCI ? ["basic"] : ["verbose"],
|
|
19
|
+
retry: isCI ? 2 : 0,
|
|
20
|
+
setupFiles: options.setupFiles,
|
|
21
|
+
testTimeout: isCI ? 30_000 : 10_000,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return defineConfig(baseConfig);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Re-export for merging with existing vite configs
|
|
29
|
+
export { mergeConfig } from "vitest/config";
|