@sablier/devkit 1.5.1 โ 1.6.1
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/package.json +18 -6
- package/tsconfig/base.json +1 -0
- package/tsconfig/build.json +1 -0
- package/tsconfig/next.json +0 -1
- package/vitest/base.js +32 -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/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.1",
|
|
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,18 @@
|
|
|
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": "./vitest/base.js"
|
|
25
35
|
},
|
|
26
36
|
"engines": {
|
|
27
37
|
"node": ">=20"
|
|
28
38
|
},
|
|
29
39
|
"files": [
|
|
30
40
|
"biome/",
|
|
31
|
-
".prettierrc.json",
|
|
32
41
|
"just/",
|
|
33
|
-
"tsconfig/"
|
|
42
|
+
"tsconfig/",
|
|
43
|
+
"vitest/",
|
|
44
|
+
".prettierrc.json"
|
|
34
45
|
],
|
|
35
46
|
"keywords": [
|
|
36
47
|
"biome",
|
|
@@ -39,7 +50,8 @@
|
|
|
39
50
|
"prettier",
|
|
40
51
|
"sablier",
|
|
41
52
|
"tsconfig",
|
|
42
|
-
"typescript"
|
|
53
|
+
"typescript",
|
|
54
|
+
"vitest"
|
|
43
55
|
],
|
|
44
56
|
"publishConfig": {
|
|
45
57
|
"access": "public"
|
package/tsconfig/base.json
CHANGED
package/tsconfig/build.json
CHANGED
package/tsconfig/next.json
CHANGED
package/vitest/base.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineConfig, mergeConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} DevkitVitestOptions
|
|
5
|
+
* @property {"node" | "jsdom" | "happy-dom"} [environment]
|
|
6
|
+
* @property {string[]} [setupFiles]
|
|
7
|
+
* @property {boolean} [coverage]
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {DevkitVitestOptions} [options]
|
|
12
|
+
*/
|
|
13
|
+
export function defineDevkitConfig(options = {}) {
|
|
14
|
+
const isCI = !!process.env.CI;
|
|
15
|
+
|
|
16
|
+
const baseConfig = {
|
|
17
|
+
test: {
|
|
18
|
+
coverage: options.coverage ? { provider: "v8" } : undefined,
|
|
19
|
+
environment: options.environment ?? "node",
|
|
20
|
+
globals: true,
|
|
21
|
+
reporters: isCI ? ["basic"] : ["verbose"],
|
|
22
|
+
retry: isCI ? 2 : 0,
|
|
23
|
+
setupFiles: options.setupFiles,
|
|
24
|
+
testTimeout: isCI ? 30_000 : 10_000,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return defineConfig(baseConfig);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Re-export for merging with existing vite configs
|
|
32
|
+
export { mergeConfig };
|