klaim 1.6.9 → 1.6.10
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/.github/workflows/update-deps.yml +57 -0
- package/Makefile +1 -10
- package/deno.json +1 -1
- package/eslint.config.mjs +210 -210
- package/index.ts +2 -2
- package/load-env.cjs +1 -1
- package/mod.ts +2 -2
- package/package.json +12 -12
- package/release-it.config.cjs +32 -34
- package/src/core/Hook.ts +32 -32
- package/src/index.ts +5 -5
- package/src/tools/cleanUrl.ts +12 -12
- package/src/tools/hashStr.ts +28 -28
- package/src/tools/toCamelCase.ts +11 -11
- package/tests/05.cache.test.ts +26 -26
- package/tests/06.retry.test.ts +43 -43
- package/vite.config.ts +40 -40
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Auto Update & Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
- cron: '0 0 * * 1'
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
update-and-release:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
contents: write
|
|
14
|
+
packages: write
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0
|
|
19
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: '20'
|
|
25
|
+
registry-url: 'https://registry.npmjs.org'
|
|
26
|
+
|
|
27
|
+
- name: Configure NPM Authentication
|
|
28
|
+
run: |
|
|
29
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
|
|
30
|
+
npm whoami
|
|
31
|
+
env:
|
|
32
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
33
|
+
|
|
34
|
+
- name: Configure Git
|
|
35
|
+
run: |
|
|
36
|
+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
37
|
+
git config --global user.name "GitHub Actions Bot"
|
|
38
|
+
|
|
39
|
+
- name: Install dependencies
|
|
40
|
+
run: npm install
|
|
41
|
+
|
|
42
|
+
- name: Update ALL dependencies
|
|
43
|
+
run: |
|
|
44
|
+
npx npm-check-updates -u
|
|
45
|
+
npm install
|
|
46
|
+
|
|
47
|
+
- name: Test and build
|
|
48
|
+
run: |
|
|
49
|
+
npm run test
|
|
50
|
+
npm run build
|
|
51
|
+
|
|
52
|
+
- name: Release
|
|
53
|
+
run: npm run release
|
|
54
|
+
env:
|
|
55
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
56
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
57
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/Makefile
CHANGED
|
@@ -34,13 +34,4 @@ release-major:
|
|
|
34
34
|
eval `ssh-agent -s`; \
|
|
35
35
|
ssh-add ~/.ssh/id_rsa; \
|
|
36
36
|
nr release:major; \
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
release-update-deps:
|
|
40
|
-
@echo "Updating dependencies..."
|
|
41
|
-
ncu -u
|
|
42
|
-
bun upgrade
|
|
43
|
-
git add .
|
|
44
|
-
git commit -m "auto dependencies upgrade"
|
|
45
|
-
make release
|
|
46
|
-
@echo "Dependencies updated successfully!"
|
|
37
|
+
)
|
package/deno.json
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -1,210 +1,210 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import stylistic from "@stylistic/eslint-plugin";
|
|
3
|
-
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
4
|
-
import JSdoc from "eslint-plugin-jsdoc";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import eslint from '@eslint/js';
|
|
8
|
-
import tseslint from 'typescript-eslint';
|
|
9
|
-
|
|
10
|
-
export default tseslint.config(
|
|
11
|
-
eslint.configs.recommended,
|
|
12
|
-
...tseslint.configs.recommended,
|
|
13
|
-
{
|
|
14
|
-
plugins: {
|
|
15
|
-
"@stylistic": stylistic,
|
|
16
|
-
"simple-import-sort": simpleImportSort,
|
|
17
|
-
"jsdoc": JSdoc
|
|
18
|
-
},
|
|
19
|
-
files: ["src/**/*.ts"],
|
|
20
|
-
rules: {
|
|
21
|
-
// ----------------------------------------
|
|
22
|
-
// ---------------------- Simple Import Sort
|
|
23
|
-
// ----------------------------------------
|
|
24
|
-
"simple-import-sort/exports": "error",
|
|
25
|
-
"simple-import-sort/imports": [
|
|
26
|
-
"error",
|
|
27
|
-
{
|
|
28
|
-
"groups": [
|
|
29
|
-
["^\u0000"],
|
|
30
|
-
["^@?\\w"],
|
|
31
|
-
["^/"],
|
|
32
|
-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
33
|
-
[
|
|
34
|
-
"^\\./(?=.*/)(?!/?$)",
|
|
35
|
-
"^\\.(?!/?$)",
|
|
36
|
-
"^\\./?$"
|
|
37
|
-
],
|
|
38
|
-
["^.+\\.s?css$"]
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
// ----------------------------------------
|
|
43
|
-
// ---------------------- TypeScript
|
|
44
|
-
// ----------------------------------------
|
|
45
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
46
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
47
|
-
"@typescript-eslint/no-dynamic-delete": "off",
|
|
48
|
-
"@typescript-eslint/no-namespace": "off",
|
|
49
|
-
"@typescript-eslint/ no-empty-object-type": "off",
|
|
50
|
-
"@typescript-eslint/explicit-function-return-type": "error",
|
|
51
|
-
"@typescript-eslint/consistent-indexed-object-style": "error",
|
|
52
|
-
|
|
53
|
-
// ----------------------------------------
|
|
54
|
-
// ---------------------- Stylistic
|
|
55
|
-
// ----------------------------------------
|
|
56
|
-
"@stylistic/array-bracket-spacing": ["error", "always"],
|
|
57
|
-
"@stylistic/function-paren-newline": ["error", "multiline"],
|
|
58
|
-
"@stylistic/multiline-ternary": ["error", "always-multiline"],
|
|
59
|
-
"@stylistic/quotes": [
|
|
60
|
-
"error",
|
|
61
|
-
"double",
|
|
62
|
-
{
|
|
63
|
-
"avoidEscape": true, "allowTemplateLiterals": true
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
"@stylistic/semi": [
|
|
67
|
-
"error",
|
|
68
|
-
"always",
|
|
69
|
-
{
|
|
70
|
-
"omitLastInOneLineBlock": true, "omitLastInOneLineClassBody": true
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
"@stylistic/space-before-function-paren": ["error", "always"],
|
|
74
|
-
"@stylistic/space-in-parens": ["error", "never"],
|
|
75
|
-
"@stylistic/space-infix-ops": ["error", {"int32Hint": false}],
|
|
76
|
-
"@stylistic/space-before-blocks": ["error", "always"],
|
|
77
|
-
"@stylistic/space-unary-ops": ["error", {"words": true, "nonwords": false}],
|
|
78
|
-
"@stylistic/keyword-spacing": ["error", {"before": true, "after": true}],
|
|
79
|
-
"@stylistic/block-spacing": ["error", "always"],
|
|
80
|
-
"@stylistic/comma-dangle": ["error", "never"],
|
|
81
|
-
"@stylistic/array-bracket-newline": ["error", {"multiline": true}],
|
|
82
|
-
"@stylistic/array-element-newline": ["error", {"multiline": true, "minItems": 3}],
|
|
83
|
-
"@stylistic/object-curly-newline": ["error", {"multiline": true, "consistent": true}],
|
|
84
|
-
"@stylistic/max-len": [
|
|
85
|
-
"error",
|
|
86
|
-
{
|
|
87
|
-
"code": 120,
|
|
88
|
-
"tabWidth": 4,
|
|
89
|
-
"ignoreComments": true,
|
|
90
|
-
"ignoreUrls": true,
|
|
91
|
-
"ignoreStrings": true,
|
|
92
|
-
"ignoreTemplateLiterals": true,
|
|
93
|
-
"ignoreRegExpLiterals": true,
|
|
94
|
-
"ignorePattern": "d=.*"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
"@stylistic/padded-blocks": ["error", "never"],
|
|
98
|
-
"@stylistic/no-multiple-empty-lines": ["error", {"max": 1, "maxEOF": 0}],
|
|
99
|
-
"@stylistic/eol-last": ["error", "always"],
|
|
100
|
-
"@stylistic/lines-between-class-members": ["error", "always"],
|
|
101
|
-
"@stylistic/brace-style": [
|
|
102
|
-
"error",
|
|
103
|
-
"1tbs",
|
|
104
|
-
{"allowSingleLine": true}
|
|
105
|
-
],
|
|
106
|
-
"@stylistic/object-curly-spacing": ["error", "always"],
|
|
107
|
-
"@stylistic/arrow-spacing": ["error", {"before": true, "after": true}],
|
|
108
|
-
"@stylistic/implicit-arrow-linebreak": ["error", "beside"],
|
|
109
|
-
"@stylistic/arrow-parens": ["error", "as-needed"],
|
|
110
|
-
"@stylistic/no-trailing-spaces": ["error"],
|
|
111
|
-
"@stylistic/no-tabs": ["error"],
|
|
112
|
-
"@stylistic/no-whitespace-before-property": ["error"],
|
|
113
|
-
"@stylistic/template-curly-spacing": ["error", "never"],
|
|
114
|
-
"@stylistic/rest-spread-spacing": ["error", "never"],
|
|
115
|
-
"@stylistic/operator-linebreak": ["error", "before"],
|
|
116
|
-
"@stylistic/type-annotation-spacing": [
|
|
117
|
-
"error",
|
|
118
|
-
{
|
|
119
|
-
"before": false, "after": true, "overrides": {
|
|
120
|
-
"arrow": {
|
|
121
|
-
"before": true, "after": true
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
],
|
|
126
|
-
"@stylistic/type-generic-spacing": ["error"],
|
|
127
|
-
"@stylistic/type-named-tuple-spacing": ["error"],
|
|
128
|
-
|
|
129
|
-
// ----------------------------------------
|
|
130
|
-
// ---------------------- JSdoc
|
|
131
|
-
// ----------------------------------------
|
|
132
|
-
"jsdoc/check-access": "error",
|
|
133
|
-
"jsdoc/check-alignment": "error",
|
|
134
|
-
"jsdoc/check-param-names": "error",
|
|
135
|
-
"jsdoc/check-property-names": "error",
|
|
136
|
-
"jsdoc/check-tag-names": "error",
|
|
137
|
-
"jsdoc/check-types": "error",
|
|
138
|
-
"jsdoc/check-values": "error",
|
|
139
|
-
"jsdoc/empty-tags": "error",
|
|
140
|
-
"jsdoc/implements-on-classes": "error",
|
|
141
|
-
"jsdoc/multiline-blocks": "error",
|
|
142
|
-
"jsdoc/no-defaults": "error",
|
|
143
|
-
"jsdoc/no-multi-asterisks": "error",
|
|
144
|
-
"jsdoc/require-jsdoc": [
|
|
145
|
-
"error",
|
|
146
|
-
{
|
|
147
|
-
"require": {
|
|
148
|
-
"FunctionDeclaration": true,
|
|
149
|
-
"MethodDefinition": true,
|
|
150
|
-
"ClassDeclaration": true,
|
|
151
|
-
"ArrowFunctionExpression": true,
|
|
152
|
-
"FunctionExpression": true
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
],
|
|
156
|
-
"jsdoc/require-param": "error",
|
|
157
|
-
"jsdoc/require-param-description": "error",
|
|
158
|
-
"jsdoc/require-param-name": "error",
|
|
159
|
-
"jsdoc/require-property": "error",
|
|
160
|
-
"jsdoc/require-property-description": "error",
|
|
161
|
-
"jsdoc/require-property-name": "error",
|
|
162
|
-
"jsdoc/require-returns": "error",
|
|
163
|
-
"jsdoc/require-returns-check": "error",
|
|
164
|
-
"jsdoc/require-returns-description": "error",
|
|
165
|
-
"jsdoc/require-yields": "error",
|
|
166
|
-
"jsdoc/require-yields-check": "error",
|
|
167
|
-
"jsdoc/tag-lines": [
|
|
168
|
-
"error",
|
|
169
|
-
"never",
|
|
170
|
-
{
|
|
171
|
-
"applyToEndTag": false,
|
|
172
|
-
"count": 1,
|
|
173
|
-
"startLines": 1,
|
|
174
|
-
"endLines": 0
|
|
175
|
-
}
|
|
176
|
-
],
|
|
177
|
-
"jsdoc/valid-types": "error",
|
|
178
|
-
|
|
179
|
-
// ----------------------------------------
|
|
180
|
-
// ---------------------- General
|
|
181
|
-
// ----------------------------------------
|
|
182
|
-
|
|
183
|
-
"no-void": "off",
|
|
184
|
-
"no-undef": "off",
|
|
185
|
-
"indent": ["error", 4],
|
|
186
|
-
"no-console": [
|
|
187
|
-
"error",
|
|
188
|
-
{
|
|
189
|
-
allow: [
|
|
190
|
-
"warn",
|
|
191
|
-
"error",
|
|
192
|
-
"info",
|
|
193
|
-
"table"
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
],
|
|
197
|
-
"camelcase": [
|
|
198
|
-
"error",
|
|
199
|
-
{
|
|
200
|
-
"properties": "never", "ignoreDestructuring": true, "allow": ["^_[a-z]+_[a-z]+$"]
|
|
201
|
-
}
|
|
202
|
-
],
|
|
203
|
-
"dot-notation": "off",
|
|
204
|
-
"no-underscore-dangle": "off",
|
|
205
|
-
"func-style": ["error", "declaration"]
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
);
|
|
210
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
import stylistic from "@stylistic/eslint-plugin";
|
|
3
|
+
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
4
|
+
import JSdoc from "eslint-plugin-jsdoc";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import eslint from '@eslint/js';
|
|
8
|
+
import tseslint from 'typescript-eslint';
|
|
9
|
+
|
|
10
|
+
export default tseslint.config(
|
|
11
|
+
eslint.configs.recommended,
|
|
12
|
+
...tseslint.configs.recommended,
|
|
13
|
+
{
|
|
14
|
+
plugins: {
|
|
15
|
+
"@stylistic": stylistic,
|
|
16
|
+
"simple-import-sort": simpleImportSort,
|
|
17
|
+
"jsdoc": JSdoc
|
|
18
|
+
},
|
|
19
|
+
files: ["src/**/*.ts"],
|
|
20
|
+
rules: {
|
|
21
|
+
// ----------------------------------------
|
|
22
|
+
// ---------------------- Simple Import Sort
|
|
23
|
+
// ----------------------------------------
|
|
24
|
+
"simple-import-sort/exports": "error",
|
|
25
|
+
"simple-import-sort/imports": [
|
|
26
|
+
"error",
|
|
27
|
+
{
|
|
28
|
+
"groups": [
|
|
29
|
+
["^\u0000"],
|
|
30
|
+
["^@?\\w"],
|
|
31
|
+
["^/"],
|
|
32
|
+
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
33
|
+
[
|
|
34
|
+
"^\\./(?=.*/)(?!/?$)",
|
|
35
|
+
"^\\.(?!/?$)",
|
|
36
|
+
"^\\./?$"
|
|
37
|
+
],
|
|
38
|
+
["^.+\\.s?css$"]
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
// ----------------------------------------
|
|
43
|
+
// ---------------------- TypeScript
|
|
44
|
+
// ----------------------------------------
|
|
45
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
46
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
47
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
48
|
+
"@typescript-eslint/no-namespace": "off",
|
|
49
|
+
"@typescript-eslint/ no-empty-object-type": "off",
|
|
50
|
+
"@typescript-eslint/explicit-function-return-type": "error",
|
|
51
|
+
"@typescript-eslint/consistent-indexed-object-style": "error",
|
|
52
|
+
|
|
53
|
+
// ----------------------------------------
|
|
54
|
+
// ---------------------- Stylistic
|
|
55
|
+
// ----------------------------------------
|
|
56
|
+
"@stylistic/array-bracket-spacing": ["error", "always"],
|
|
57
|
+
"@stylistic/function-paren-newline": ["error", "multiline"],
|
|
58
|
+
"@stylistic/multiline-ternary": ["error", "always-multiline"],
|
|
59
|
+
"@stylistic/quotes": [
|
|
60
|
+
"error",
|
|
61
|
+
"double",
|
|
62
|
+
{
|
|
63
|
+
"avoidEscape": true, "allowTemplateLiterals": true
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"@stylistic/semi": [
|
|
67
|
+
"error",
|
|
68
|
+
"always",
|
|
69
|
+
{
|
|
70
|
+
"omitLastInOneLineBlock": true, "omitLastInOneLineClassBody": true
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"@stylistic/space-before-function-paren": ["error", "always"],
|
|
74
|
+
"@stylistic/space-in-parens": ["error", "never"],
|
|
75
|
+
"@stylistic/space-infix-ops": ["error", {"int32Hint": false}],
|
|
76
|
+
"@stylistic/space-before-blocks": ["error", "always"],
|
|
77
|
+
"@stylistic/space-unary-ops": ["error", {"words": true, "nonwords": false}],
|
|
78
|
+
"@stylistic/keyword-spacing": ["error", {"before": true, "after": true}],
|
|
79
|
+
"@stylistic/block-spacing": ["error", "always"],
|
|
80
|
+
"@stylistic/comma-dangle": ["error", "never"],
|
|
81
|
+
"@stylistic/array-bracket-newline": ["error", {"multiline": true}],
|
|
82
|
+
"@stylistic/array-element-newline": ["error", {"multiline": true, "minItems": 3}],
|
|
83
|
+
"@stylistic/object-curly-newline": ["error", {"multiline": true, "consistent": true}],
|
|
84
|
+
"@stylistic/max-len": [
|
|
85
|
+
"error",
|
|
86
|
+
{
|
|
87
|
+
"code": 120,
|
|
88
|
+
"tabWidth": 4,
|
|
89
|
+
"ignoreComments": true,
|
|
90
|
+
"ignoreUrls": true,
|
|
91
|
+
"ignoreStrings": true,
|
|
92
|
+
"ignoreTemplateLiterals": true,
|
|
93
|
+
"ignoreRegExpLiterals": true,
|
|
94
|
+
"ignorePattern": "d=.*"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"@stylistic/padded-blocks": ["error", "never"],
|
|
98
|
+
"@stylistic/no-multiple-empty-lines": ["error", {"max": 1, "maxEOF": 0}],
|
|
99
|
+
"@stylistic/eol-last": ["error", "always"],
|
|
100
|
+
"@stylistic/lines-between-class-members": ["error", "always"],
|
|
101
|
+
"@stylistic/brace-style": [
|
|
102
|
+
"error",
|
|
103
|
+
"1tbs",
|
|
104
|
+
{"allowSingleLine": true}
|
|
105
|
+
],
|
|
106
|
+
"@stylistic/object-curly-spacing": ["error", "always"],
|
|
107
|
+
"@stylistic/arrow-spacing": ["error", {"before": true, "after": true}],
|
|
108
|
+
"@stylistic/implicit-arrow-linebreak": ["error", "beside"],
|
|
109
|
+
"@stylistic/arrow-parens": ["error", "as-needed"],
|
|
110
|
+
"@stylistic/no-trailing-spaces": ["error"],
|
|
111
|
+
"@stylistic/no-tabs": ["error"],
|
|
112
|
+
"@stylistic/no-whitespace-before-property": ["error"],
|
|
113
|
+
"@stylistic/template-curly-spacing": ["error", "never"],
|
|
114
|
+
"@stylistic/rest-spread-spacing": ["error", "never"],
|
|
115
|
+
"@stylistic/operator-linebreak": ["error", "before"],
|
|
116
|
+
"@stylistic/type-annotation-spacing": [
|
|
117
|
+
"error",
|
|
118
|
+
{
|
|
119
|
+
"before": false, "after": true, "overrides": {
|
|
120
|
+
"arrow": {
|
|
121
|
+
"before": true, "after": true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"@stylistic/type-generic-spacing": ["error"],
|
|
127
|
+
"@stylistic/type-named-tuple-spacing": ["error"],
|
|
128
|
+
|
|
129
|
+
// ----------------------------------------
|
|
130
|
+
// ---------------------- JSdoc
|
|
131
|
+
// ----------------------------------------
|
|
132
|
+
"jsdoc/check-access": "error",
|
|
133
|
+
"jsdoc/check-alignment": "error",
|
|
134
|
+
"jsdoc/check-param-names": "error",
|
|
135
|
+
"jsdoc/check-property-names": "error",
|
|
136
|
+
"jsdoc/check-tag-names": "error",
|
|
137
|
+
"jsdoc/check-types": "error",
|
|
138
|
+
"jsdoc/check-values": "error",
|
|
139
|
+
"jsdoc/empty-tags": "error",
|
|
140
|
+
"jsdoc/implements-on-classes": "error",
|
|
141
|
+
"jsdoc/multiline-blocks": "error",
|
|
142
|
+
"jsdoc/no-defaults": "error",
|
|
143
|
+
"jsdoc/no-multi-asterisks": "error",
|
|
144
|
+
"jsdoc/require-jsdoc": [
|
|
145
|
+
"error",
|
|
146
|
+
{
|
|
147
|
+
"require": {
|
|
148
|
+
"FunctionDeclaration": true,
|
|
149
|
+
"MethodDefinition": true,
|
|
150
|
+
"ClassDeclaration": true,
|
|
151
|
+
"ArrowFunctionExpression": true,
|
|
152
|
+
"FunctionExpression": true
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"jsdoc/require-param": "error",
|
|
157
|
+
"jsdoc/require-param-description": "error",
|
|
158
|
+
"jsdoc/require-param-name": "error",
|
|
159
|
+
"jsdoc/require-property": "error",
|
|
160
|
+
"jsdoc/require-property-description": "error",
|
|
161
|
+
"jsdoc/require-property-name": "error",
|
|
162
|
+
"jsdoc/require-returns": "error",
|
|
163
|
+
"jsdoc/require-returns-check": "error",
|
|
164
|
+
"jsdoc/require-returns-description": "error",
|
|
165
|
+
"jsdoc/require-yields": "error",
|
|
166
|
+
"jsdoc/require-yields-check": "error",
|
|
167
|
+
"jsdoc/tag-lines": [
|
|
168
|
+
"error",
|
|
169
|
+
"never",
|
|
170
|
+
{
|
|
171
|
+
"applyToEndTag": false,
|
|
172
|
+
"count": 1,
|
|
173
|
+
"startLines": 1,
|
|
174
|
+
"endLines": 0
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
"jsdoc/valid-types": "error",
|
|
178
|
+
|
|
179
|
+
// ----------------------------------------
|
|
180
|
+
// ---------------------- General
|
|
181
|
+
// ----------------------------------------
|
|
182
|
+
|
|
183
|
+
"no-void": "off",
|
|
184
|
+
"no-undef": "off",
|
|
185
|
+
"indent": ["error", 4],
|
|
186
|
+
"no-console": [
|
|
187
|
+
"error",
|
|
188
|
+
{
|
|
189
|
+
allow: [
|
|
190
|
+
"warn",
|
|
191
|
+
"error",
|
|
192
|
+
"info",
|
|
193
|
+
"table"
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"camelcase": [
|
|
198
|
+
"error",
|
|
199
|
+
{
|
|
200
|
+
"properties": "never", "ignoreDestructuring": true, "allow": ["^_[a-z]+_[a-z]+$"]
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"dot-notation": "off",
|
|
204
|
+
"no-underscore-dangle": "off",
|
|
205
|
+
"func-style": ["error", "declaration"]
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
|
package/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './src';
|
|
2
|
-
|
|
1
|
+
export * from './src';
|
|
2
|
+
|
package/load-env.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require('dotenv').config();
|
|
1
|
+
require('dotenv').config();
|
package/mod.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './src';
|
|
2
|
-
|
|
1
|
+
export * from './src';
|
|
2
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klaim",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
4
4
|
"author": "antharuu",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,22 +9,22 @@
|
|
|
9
9
|
"main": "dist/klaim.cjs.js",
|
|
10
10
|
"module": "dist/klaim.es.js",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@eslint/js": "^9.
|
|
13
|
-
"@stylistic/eslint-plugin": "^2.
|
|
12
|
+
"@eslint/js": "^9.13.0",
|
|
13
|
+
"@stylistic/eslint-plugin": "^2.9.0",
|
|
14
14
|
"@types/bun": "latest",
|
|
15
15
|
"@types/eslint__js": "^8.42.3",
|
|
16
|
-
"@types/node": "^22.
|
|
17
|
-
"@vitest/coverage-v8": "^2.1.
|
|
18
|
-
"@vitest/ui": "^2.1.
|
|
16
|
+
"@types/node": "^22.8.2",
|
|
17
|
+
"@vitest/coverage-v8": "^2.1.4",
|
|
18
|
+
"@vitest/ui": "^2.1.4",
|
|
19
19
|
"dotenv-cli": "^7.4.2",
|
|
20
|
-
"eslint": "^9.
|
|
21
|
-
"eslint-plugin-jsdoc": "^50.
|
|
20
|
+
"eslint": "^9.13.0",
|
|
21
|
+
"eslint-plugin-jsdoc": "^50.4.3",
|
|
22
22
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
23
23
|
"jsdom": "^25.0.1",
|
|
24
|
-
"release-it": "^17.
|
|
25
|
-
"typescript-eslint": "^8.
|
|
26
|
-
"vite": "^5.4.
|
|
27
|
-
"vitest": "^2.1.
|
|
24
|
+
"release-it": "^17.10.0",
|
|
25
|
+
"typescript-eslint": "^8.12.1",
|
|
26
|
+
"vite": "^5.4.10",
|
|
27
|
+
"vitest": "^2.1.4",
|
|
28
28
|
"yup": "^1.4.0"
|
|
29
29
|
},
|
|
30
30
|
"bugs": {
|
package/release-it.config.cjs
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
// release-it.config.cjs
|
|
2
|
-
require('./load-env.cjs');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
github: {
|
|
6
|
-
release: false,
|
|
7
|
-
},
|
|
8
|
-
npm: {
|
|
9
|
-
publish:
|
|
10
|
-
},
|
|
11
|
-
git: {
|
|
12
|
-
tagName: "v${version}",
|
|
13
|
-
requiredBranch: 'main',
|
|
14
|
-
requireCleanWorkingDir: false,
|
|
15
|
-
commitMessage: "chore: release v${version}",
|
|
16
|
-
tag: true,
|
|
17
|
-
push: true,
|
|
18
|
-
commit: true,
|
|
19
|
-
publish: true,
|
|
20
|
-
},
|
|
21
|
-
hooks: {
|
|
22
|
-
'before:init': [
|
|
23
|
-
'git pull',
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
],
|
|
27
|
-
'after:bump': [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
};
|
|
1
|
+
// release-it.config.cjs
|
|
2
|
+
require('./load-env.cjs');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
github: {
|
|
6
|
+
release: false,
|
|
7
|
+
},
|
|
8
|
+
npm: {
|
|
9
|
+
publish: true,
|
|
10
|
+
},
|
|
11
|
+
git: {
|
|
12
|
+
tagName: "v${version}",
|
|
13
|
+
requiredBranch: 'main',
|
|
14
|
+
requireCleanWorkingDir: false,
|
|
15
|
+
commitMessage: "chore: release v${version}",
|
|
16
|
+
tag: true,
|
|
17
|
+
push: true,
|
|
18
|
+
commit: true,
|
|
19
|
+
publish: true,
|
|
20
|
+
},
|
|
21
|
+
hooks: {
|
|
22
|
+
'before:init': [
|
|
23
|
+
'git pull',
|
|
24
|
+
'npm run lint',
|
|
25
|
+
'npm run build'
|
|
26
|
+
],
|
|
27
|
+
'after:bump': [
|
|
28
|
+
'make update-version-deno',
|
|
29
|
+
'npx jsr publish --allow-dirty'
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
};
|
package/src/core/Hook.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
type IHookCallback = () => any;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents hooks
|
|
5
|
-
*/
|
|
6
|
-
export class Hook {
|
|
7
|
-
private static _callbacks: Map<string, IHookCallback> = new Map<string, IHookCallback>();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Subscribes to the hook
|
|
11
|
-
*
|
|
12
|
-
* @param routeName - The name of the route to subscribe to
|
|
13
|
-
* @param callback - The callback to subscribe
|
|
14
|
-
*/
|
|
15
|
-
public static subscribe (routeName: string, callback: IHookCallback): void {
|
|
16
|
-
this._callbacks.set(routeName, callback);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Runs the hook
|
|
21
|
-
*
|
|
22
|
-
* @param routeName - The name of the route to run
|
|
23
|
-
*/
|
|
24
|
-
public static run (routeName: string): void {
|
|
25
|
-
const callback = this._callbacks.get(routeName);
|
|
26
|
-
if (!callback) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
callback();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
type IHookCallback = () => any;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents hooks
|
|
5
|
+
*/
|
|
6
|
+
export class Hook {
|
|
7
|
+
private static _callbacks: Map<string, IHookCallback> = new Map<string, IHookCallback>();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Subscribes to the hook
|
|
11
|
+
*
|
|
12
|
+
* @param routeName - The name of the route to subscribe to
|
|
13
|
+
* @param callback - The callback to subscribe
|
|
14
|
+
*/
|
|
15
|
+
public static subscribe (routeName: string, callback: IHookCallback): void {
|
|
16
|
+
this._callbacks.set(routeName, callback);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs the hook
|
|
21
|
+
*
|
|
22
|
+
* @param routeName - The name of the route to run
|
|
23
|
+
*/
|
|
24
|
+
public static run (routeName: string): void {
|
|
25
|
+
const callback = this._callbacks.get(routeName);
|
|
26
|
+
if (!callback) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
callback();
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Api } from "./core/Api";
|
|
2
|
-
export { Hook } from "./core/Hook";
|
|
3
|
-
export { Klaim } from "./core/Klaim";
|
|
4
|
-
export { Registry } from "./core/Registry";
|
|
5
|
-
export { Route } from "./core/Route";
|
|
1
|
+
export { Api } from "./core/Api";
|
|
2
|
+
export { Hook } from "./core/Hook";
|
|
3
|
+
export { Klaim } from "./core/Klaim";
|
|
4
|
+
export { Registry } from "./core/Registry";
|
|
5
|
+
export { Route } from "./core/Route";
|
package/src/tools/cleanUrl.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clean the URL by removing slashes at the beginning and end of the string.
|
|
3
|
-
*
|
|
4
|
-
* @param url - The URL to clean
|
|
5
|
-
* @returns The cleaned URL
|
|
6
|
-
*/
|
|
7
|
-
export default function (url: string): string {
|
|
8
|
-
return url
|
|
9
|
-
.trim()
|
|
10
|
-
// remove slashes at the beginning and end of the string
|
|
11
|
-
.replace(/^\/|\/$/g, "");
|
|
12
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Clean the URL by removing slashes at the beginning and end of the string.
|
|
3
|
+
*
|
|
4
|
+
* @param url - The URL to clean
|
|
5
|
+
* @returns The cleaned URL
|
|
6
|
+
*/
|
|
7
|
+
export default function (url: string): string {
|
|
8
|
+
return url
|
|
9
|
+
.trim()
|
|
10
|
+
// remove slashes at the beginning and end of the string
|
|
11
|
+
.replace(/^\/|\/$/g, "");
|
|
12
|
+
}
|
package/src/tools/hashStr.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculates the hash value of a given string.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} str - The string to calculate the hash for.
|
|
5
|
-
* @returns {string} The hash value of the input string.
|
|
6
|
-
*/
|
|
7
|
-
export default function (str: string): string {
|
|
8
|
-
const initialHash = 0x811c9dc5;
|
|
9
|
-
const prime = 0x01000193;
|
|
10
|
-
let hash = initialHash;
|
|
11
|
-
|
|
12
|
-
for (let i = 0; i < str.length; i++) {
|
|
13
|
-
hash ^= str.charCodeAt(i);
|
|
14
|
-
hash *= prime;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Convert the integer hash to a hexadecimal string
|
|
18
|
-
let hexHash = (hash >>> 0).toString(16).padStart(8, "0");
|
|
19
|
-
|
|
20
|
-
// Extend the hash to 32 characters by rehashing and concatenating
|
|
21
|
-
while (hexHash.length < 32) {
|
|
22
|
-
hash ^= hexHash.charCodeAt(hexHash.length % hexHash.length);
|
|
23
|
-
hash *= prime;
|
|
24
|
-
hexHash += (hash >>> 0).toString(16).padStart(8, "0");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return hexHash.substring(0, 32);
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the hash value of a given string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string to calculate the hash for.
|
|
5
|
+
* @returns {string} The hash value of the input string.
|
|
6
|
+
*/
|
|
7
|
+
export default function (str: string): string {
|
|
8
|
+
const initialHash = 0x811c9dc5;
|
|
9
|
+
const prime = 0x01000193;
|
|
10
|
+
let hash = initialHash;
|
|
11
|
+
|
|
12
|
+
for (let i = 0; i < str.length; i++) {
|
|
13
|
+
hash ^= str.charCodeAt(i);
|
|
14
|
+
hash *= prime;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Convert the integer hash to a hexadecimal string
|
|
18
|
+
let hexHash = (hash >>> 0).toString(16).padStart(8, "0");
|
|
19
|
+
|
|
20
|
+
// Extend the hash to 32 characters by rehashing and concatenating
|
|
21
|
+
while (hexHash.length < 32) {
|
|
22
|
+
hash ^= hexHash.charCodeAt(hexHash.length % hexHash.length);
|
|
23
|
+
hash *= prime;
|
|
24
|
+
hexHash += (hash >>> 0).toString(16).padStart(8, "0");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return hexHash.substring(0, 32);
|
|
28
|
+
}
|
package/src/tools/toCamelCase.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert a string to camel case
|
|
3
|
-
*
|
|
4
|
-
* @param text - The text to convert
|
|
5
|
-
* @returns The text in camel case
|
|
6
|
-
*/
|
|
7
|
-
export default function (text: string): string {
|
|
8
|
-
return text
|
|
9
|
-
.replace(/([-_][a-z])/gi, match => match.toUpperCase().replace("-", "").replace("_", ""))
|
|
10
|
-
.replace(/(^\w)/, match => match.toLowerCase());
|
|
11
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string to camel case
|
|
3
|
+
*
|
|
4
|
+
* @param text - The text to convert
|
|
5
|
+
* @returns The text in camel case
|
|
6
|
+
*/
|
|
7
|
+
export default function (text: string): string {
|
|
8
|
+
return text
|
|
9
|
+
.replace(/([-_][a-z])/gi, match => match.toUpperCase().replace("-", "").replace("_", ""))
|
|
10
|
+
.replace(/(^\w)/, match => match.toLowerCase());
|
|
11
|
+
}
|
package/tests/05.cache.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { Api, Klaim,
|
|
2
|
+
import { Api, Klaim, Route } from "../src/index";
|
|
3
3
|
|
|
4
4
|
const apiName = "testApi";
|
|
5
5
|
const apiUrl = "https://lorem-json.com/api/";
|
|
@@ -7,40 +7,40 @@ const apiUrl = "https://lorem-json.com/api/";
|
|
|
7
7
|
const routeName = "testRoute";
|
|
8
8
|
const routeUrl = "/json";
|
|
9
9
|
const routeBody = {
|
|
10
|
-
|
|
10
|
+
"name": "{{name()}}",
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
await describe("Cache", async () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
it("should not cache the API response", async () => {
|
|
15
|
+
Api.create(apiName, apiUrl, () => {
|
|
16
|
+
Route.post(routeName, routeUrl);
|
|
17
|
+
});
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const { name: nameA } = await Klaim[apiName][routeName]({}, routeBody);
|
|
20
|
+
const { name: nameB } = await Klaim[apiName][routeName]({}, routeBody);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
expect(nameA).not.toEqual(nameB);
|
|
23
|
+
});
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
it("should keep the API response in cache", async () => {
|
|
26
|
+
Api.create(apiName, apiUrl, () => {
|
|
27
|
+
Route.post(routeName, routeUrl);
|
|
28
|
+
}).withCache();
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const { name: nameA } = await Klaim[apiName][routeName]({}, routeBody);
|
|
31
|
+
const { name: nameB } = await Klaim[apiName][routeName]({}, routeBody);
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
expect(nameA).toEqual(nameB);
|
|
34
|
+
});
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
it("should keep the route response in cache", async () => {
|
|
37
|
+
Api.create(apiName, apiUrl, () => {
|
|
38
|
+
Route.post(routeName, routeUrl).withCache();
|
|
39
|
+
});
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const { name: nameA } = await Klaim[apiName][routeName]({}, routeBody);
|
|
42
|
+
const { name: nameB } = await Klaim[apiName][routeName]({}, routeBody);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
expect(nameA).toEqual(nameB);
|
|
45
|
+
});
|
|
46
46
|
});
|
package/tests/06.retry.test.ts
CHANGED
|
@@ -8,47 +8,47 @@ const routeName = "testRoute";
|
|
|
8
8
|
const routeUrl = "/fake/1";
|
|
9
9
|
|
|
10
10
|
await describe("Retry", async () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
11
|
+
it("should just fail", async () => {
|
|
12
|
+
let a = 0;
|
|
13
|
+
Api.create(apiName, apiUrl, () => {
|
|
14
|
+
Route.post(routeName, routeUrl)
|
|
15
|
+
.onCall(() => a++);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
expect(Klaim[apiName][routeName]()).rejects.toThrow();
|
|
19
|
+
expect(a).toEqual(1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should retry api", async () => {
|
|
23
|
+
let a = 0;
|
|
24
|
+
Api.create(apiName, apiUrl, () => {
|
|
25
|
+
Route.post(routeName, routeUrl)
|
|
26
|
+
.onCall(() => a++);
|
|
27
|
+
})
|
|
28
|
+
.onCall(() => a--) // Never call route > api
|
|
29
|
+
.withRetry(3);
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await Klaim[apiName][routeName]();
|
|
33
|
+
} catch {
|
|
34
|
+
// Dont care
|
|
35
|
+
}
|
|
36
|
+
expect(a).toEqual(4);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should retry route", async () => {
|
|
40
|
+
let a = 0;
|
|
41
|
+
Api.create(apiName, apiUrl, () => {
|
|
42
|
+
Route.post(routeName, routeUrl)
|
|
43
|
+
.onCall(() => a++)
|
|
44
|
+
.withRetry(3);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
await Klaim[apiName][routeName]();
|
|
49
|
+
} catch {
|
|
50
|
+
// Dont care
|
|
51
|
+
}
|
|
52
|
+
expect(a).toEqual(4);
|
|
53
|
+
});
|
|
54
54
|
});
|
package/vite.config.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
import { configDefaults } from "vitest/config";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
build: {
|
|
7
|
-
lib: {
|
|
8
|
-
entry: path.resolve(__dirname, "src/index.ts"),
|
|
9
|
-
name: "klaim",
|
|
10
|
-
fileName: (format) => {
|
|
11
|
-
if (format === "cjs") return `klaim.${format}`;
|
|
12
|
-
return `klaim.${format}.js`;
|
|
13
|
-
},
|
|
14
|
-
formats: ["es", "cjs", "umd"],
|
|
15
|
-
},
|
|
16
|
-
rollupOptions: {
|
|
17
|
-
external: [],
|
|
18
|
-
output: {
|
|
19
|
-
globals: {},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
test: {
|
|
24
|
-
globals: true,
|
|
25
|
-
environment: "jsdom",
|
|
26
|
-
exclude: [
|
|
27
|
-
...configDefaults.exclude,
|
|
28
|
-
"tests/e2e/**",
|
|
29
|
-
],
|
|
30
|
-
coverage: {
|
|
31
|
-
provider: "v8",
|
|
32
|
-
exclude: [
|
|
33
|
-
"**/*.cjs",
|
|
34
|
-
"index.ts",
|
|
35
|
-
"mod.ts",
|
|
36
|
-
"src/core/Registry.ts",
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
});
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { configDefaults } from "vitest/config";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
build: {
|
|
7
|
+
lib: {
|
|
8
|
+
entry: path.resolve(__dirname, "src/index.ts"),
|
|
9
|
+
name: "klaim",
|
|
10
|
+
fileName: (format) => {
|
|
11
|
+
if (format === "cjs") return `klaim.${format}`;
|
|
12
|
+
return `klaim.${format}.js`;
|
|
13
|
+
},
|
|
14
|
+
formats: ["es", "cjs", "umd"],
|
|
15
|
+
},
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
external: [],
|
|
18
|
+
output: {
|
|
19
|
+
globals: {},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
test: {
|
|
24
|
+
globals: true,
|
|
25
|
+
environment: "jsdom",
|
|
26
|
+
exclude: [
|
|
27
|
+
...configDefaults.exclude,
|
|
28
|
+
"tests/e2e/**",
|
|
29
|
+
],
|
|
30
|
+
coverage: {
|
|
31
|
+
provider: "v8",
|
|
32
|
+
exclude: [
|
|
33
|
+
"**/*.cjs",
|
|
34
|
+
"index.ts",
|
|
35
|
+
"mod.ts",
|
|
36
|
+
"src/core/Registry.ts",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|