-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.aliases.ts
More file actions
84 lines (81 loc) · 2.78 KB
/
Copy pathvitest.aliases.ts
File metadata and controls
84 lines (81 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { resolve } from "node:path";
/**
* Subpaths whose source files live under `packages/mobility-core/src/types/`.
* Everything else (cache, policy, dedup, gbfs-*, mapper, motis-rentals,
* nominatim, entur-mobility) lives at `packages/mobility-core/src/`.
*/
const MOBILITY_CORE_TYPE_SUBPATHS = [
"attribution",
"freshness",
"result",
"parking",
"fuel",
"ev-charging",
"transit",
];
export function createRepoVitestAliases(repoRoot: string) {
const mobilityCoreTypeAliases = MOBILITY_CORE_TYPE_SUBPATHS.map((sub) => ({
find: new RegExp(`^@openmapx/mobility-core/${sub}(?:\\.js)?$`),
replacement: resolve(repoRoot, `packages/mobility-core/src/types/${sub}.ts`),
}));
return [
{
find: /^@openmapx\/core\/server$/,
replacement: resolve(repoRoot, "packages/core/src/server.ts"),
},
{
find: /^@openmapx\/core$/,
replacement: resolve(repoRoot, "packages/core/src/index.ts"),
},
// The `./types` subpath is the SharedMobility* type bundle (renamed from
// the old root `types.ts` to `src/types/shared-mobility.ts`).
{
find: /^@openmapx\/mobility-core\/types$/,
replacement: resolve(repoRoot, "packages/mobility-core/src/types/shared-mobility.ts"),
},
...mobilityCoreTypeAliases,
// Everything else under the package resolves to `src/<sub>.ts`.
{
find: /^@openmapx\/mobility-core\/(.+?)(?:\.js)?$/,
replacement: resolve(repoRoot, "packages/mobility-core/src/$1.ts"),
},
{
find: /^@openmapx\/mobility-core$/,
replacement: resolve(repoRoot, "packages/mobility-core/src"),
},
{
find: /^@openmapx\/mobility-formats$/,
replacement: resolve(repoRoot, "packages/mobility-formats/index.ts"),
},
{
find: /^@openmapx\/integration-framework\/testing$/,
replacement: resolve(repoRoot, "packages/integration-framework/src/testing/index.ts"),
},
{
find: /^@openmapx\/integration-framework\/installer$/,
replacement: resolve(repoRoot, "packages/integration-framework/src/installer.ts"),
},
{
find: /^@openmapx\/integration-framework$/,
replacement: resolve(repoRoot, "packages/integration-framework/src/index.ts"),
},
{
find: /^@openmapx\/extension-sdk\/testing$/,
replacement: resolve(repoRoot, "packages/extension-sdk/src/testing.ts"),
},
{
find: /^@openmapx\/extension-sdk$/,
replacement: resolve(repoRoot, "packages/extension-sdk/src/index.ts"),
},
{
find: /^@integrations\/(.+)$/,
replacement: resolve(repoRoot, "integrations/$1"),
},
// `@/*` resolves to `apps/web/src/*` to match the Next.js path alias so
// tests can import the web app's source modules.
{
find: /^@\/(.+)$/,
replacement: resolve(repoRoot, "apps/web/src/$1"),
},
];
}