vitest-config-silverwind 9.0.6 → 9.1.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/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { InlineConfig } from 'vitest';
1
+ import { InlineConfig } from 'vitest/node';
2
2
  import { UserConfig } from 'vite';
3
-
4
3
  type VitestConfig = UserConfig & {
5
4
  test?: InlineConfig;
6
5
  };
7
6
  type CustomConfig = VitestConfig & {
8
7
  /** The value of import.meta.url from your config. */
9
- url?: string;
8
+ url: string;
10
9
  };
11
10
  export declare const frontend: ({ test, ...other }?: CustomConfig) => VitestConfig;
12
11
  export declare const backend: ({ test, ...other }?: CustomConfig) => VitestConfig;
13
12
  export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAS,UAAU,EAAe,MAAM,MAAM,CAAC;AAE3D,KAAK,YAAY,GAAG,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC;AACzD,KAAK,YAAY,GAAG,YAAY,GAAG;IACjC,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAwFF,eAAO,MAAM,QAAQ,wBAA2B,YAAY,KAAmB,YAM7E,CAAC;AAEH,eAAO,MAAM,OAAO,wBAA2B,YAAY,KAAmB,YAM5E,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,17 @@
1
1
  import { dirname, relative, sep, join, basename } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
+ import { accessSync, constants } from "node:fs";
3
4
  import { stringPlugin } from "vite-string-plugin";
4
- const uniq = (arr) => Array.from(new Set(arr));
5
- const uniquePluginName = (plugin) => {
5
+ const defaultConfig = {
6
+ url: ""
7
+ };
8
+ function uniq(arr) {
9
+ return Array.from(new Set(arr));
10
+ }
11
+ function uniquePluginName(plugin) {
6
12
  const apply = typeof plugin.apply === "string" ? plugin.apply : "";
7
13
  return `${plugin.name}-${apply}-${String(plugin.enforce)}`;
8
- };
14
+ }
9
15
  function dedupePlugins(libPlugins, userPlugins) {
10
16
  const seen = /* @__PURE__ */ new Set([]);
11
17
  const ret = [];
@@ -22,54 +28,66 @@ function dedupePlugins(libPlugins, userPlugins) {
22
28
  }
23
29
  return ret;
24
30
  }
25
- const setupFile = "vitest.setup.js";
26
- const base = ({ url, test: { setupFiles = [], ...otherTest } = {}, plugins = [], ...other } = {}) => ({
27
- test: {
28
- include: [
29
- "**/?(*.)test.?(c|m)[jt]s?(x)"
30
- ],
31
- exclude: [
32
- "**/{node_modules,dist,e2e,snapshots}/**",
33
- "**/.{air,git,github,gitea,swc,ruff_cache,venv,vscode}/**"
34
- ],
35
- setupFiles: uniq([
36
- fileURLToPath(new URL(setupFile, import.meta.url)),
37
- ...setupFiles
38
- ]),
39
- testTimeout: 3e4,
40
- pool: "forks",
41
- // https://github.com/vitest-dev/vitest/issues/2008
42
- cache: false,
43
- // https://github.com/vitest-dev/vitest/issues/2008
44
- open: false,
45
- allowOnly: true,
46
- passWithNoTests: true,
47
- globals: true,
48
- watch: false,
49
- resolveSnapshotPath: (path, extension) => {
50
- if (url) {
51
- const root = dirname(fileURLToPath(new URL(url)));
52
- const file = `${relative(root, path).replaceAll(sep, ".")}${extension}`;
53
- return join(root, "snapshots", file);
54
- } else {
55
- return join(dirname(path), "snapshots", `${basename(path)}${extension}`);
56
- }
31
+ const setupFileJs = "vitest.setup.js";
32
+ const setupFileTs = "vitest.setup.ts";
33
+ function base({ url, test: { setupFiles = [], ...otherTest } = {}, plugins = [], ...other }) {
34
+ let setupFile = "";
35
+ for (const file of [setupFileJs, setupFileTs]) {
36
+ try {
37
+ const path = fileURLToPath(new URL(file, import.meta.url));
38
+ accessSync(path, constants.R_OK);
39
+ setupFile = path;
40
+ } catch {
41
+ }
42
+ }
43
+ return {
44
+ test: {
45
+ include: [
46
+ "**/?(*.)test.?(c|m)[jt]s?(x)"
47
+ ],
48
+ exclude: [
49
+ "**/{node_modules,dist,e2e,snapshots}/**",
50
+ "**/.{air,git,github,gitea,swc,ruff_cache,venv,vscode}/**"
51
+ ],
52
+ setupFiles: uniq([
53
+ setupFile,
54
+ ...setupFiles
55
+ ].filter(Boolean)),
56
+ testTimeout: 3e4,
57
+ pool: "forks",
58
+ // https://github.com/vitest-dev/vitest/issues/2008
59
+ cache: false,
60
+ // https://github.com/vitest-dev/vitest/issues/2008
61
+ open: false,
62
+ allowOnly: true,
63
+ passWithNoTests: true,
64
+ globals: true,
65
+ watch: false,
66
+ resolveSnapshotPath: (path, extension) => {
67
+ if (url) {
68
+ const root = dirname(fileURLToPath(new URL(url)));
69
+ const file = `${relative(root, path).replaceAll(sep, ".")}${extension}`;
70
+ return join(root, "snapshots", file);
71
+ } else {
72
+ return join(dirname(path), "snapshots", `${basename(path)}${extension}`);
73
+ }
74
+ },
75
+ ...otherTest
57
76
  },
58
- ...otherTest
59
- },
60
- plugins: dedupePlugins([
61
- stringPlugin()
62
- ], plugins),
63
- ...other
64
- });
65
- const frontend = ({ test = {}, ...other } = {}) => base({
77
+ plugins: dedupePlugins([
78
+ stringPlugin()
79
+ ], plugins),
80
+ ...other
81
+ };
82
+ }
83
+ const frontend = ({ test = {}, ...other } = defaultConfig) => base({
66
84
  test: {
67
85
  environment: "happy-dom",
68
86
  ...test
69
87
  },
70
88
  ...other
71
89
  });
72
- const backend = ({ test = {}, ...other } = {}) => base({
90
+ const backend = ({ test = {}, ...other } = defaultConfig) => base({
73
91
  test: {
74
92
  environment: "node",
75
93
  ...test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-config-silverwind",
3
- "version": "9.0.6",
3
+ "version": "9.1.1",
4
4
  "description": "Shared vitest configuration",
5
5
  "author": "silverwind <me@silverwind.io>",
6
6
  "repository": "silverwind/vitest-config-silverwind",
@@ -18,21 +18,21 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "jest-extended": "4.0.2",
21
- "vite-string-plugin": "^1.3.1"
21
+ "vite-string-plugin": "^1.3.4"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/node": "20.12.10",
24
+ "@types/node": "22.10.0",
25
25
  "eslint": "8.57.0",
26
- "eslint-config-silverwind": "84.0.1",
27
- "eslint-config-silverwind-typescript": "3.2.5",
26
+ "eslint-config-silverwind": "94.1.2",
27
+ "eslint-config-silverwind-typescript": "9.2.0",
28
28
  "js-yaml": "4.1.0",
29
- "typescript": "5.4.5",
30
- "typescript-config-silverwind": "4.1.0",
31
- "updates": "16.0.1",
32
- "versions": "12.0.1",
33
- "vite": "5.2.11",
34
- "vite-plugin-dts": "3.9.1",
35
- "vitest": "1.6.0"
29
+ "typescript": "5.7.2",
30
+ "typescript-config-silverwind": "6.1.0",
31
+ "updates": "16.4.0",
32
+ "versions": "12.1.2",
33
+ "vite": "5.3.3",
34
+ "vite-plugin-dts": "4.3.0",
35
+ "vitest": "2.1.6"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "happy-dom": "*"