-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
66 lines (59 loc) · 1.9 KB
/
Copy pathvite.config.ts
File metadata and controls
66 lines (59 loc) · 1.9 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
// This file is Free Software under the Apache-2.0 License
// without warranty, see README.md and LICENSES/Apache-2.0.txt for details.
//
// SPDX-License-Identifier: Apache-2.0
//
// SPDX-FileCopyrightText: 2023 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
// Software-Engineering: 2023 Intevation GmbH <https://intevation.de>
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vitest/config";
import { execSync } from "child_process";
function getSemverVersion() {
try {
const raw = execSync("git describe --tags --long --always", { encoding: "utf8" }).trim();
// Example: v1.2.3-4-gf123abc
const match = raw.match(/^v?(\d+\.\d+\.\d+)(?:-(\d+)-g([0-9a-f]+))?$/);
if (!match) {
throw new Error(`Unrecognized version format: ${raw}`);
}
const [, version, commitsSinceTag, gitSha] = match;
if (commitsSinceTag && gitSha) {
// Increment patch version
const parts = version.split(".");
parts[parts.length - 1] = (parseInt(parts[parts.length - 1]) + 1).toString();
const incrementVersion = parts.join(".");
return `${incrementVersion}-${commitsSinceTag}.g${gitSha}`;
}
return version;
} catch (err) {
console.error("Failed to get git version: " + err);
console.warn("Using placeholder version");
return "999.0.0-0";
}
}
export default defineConfig({
server: {
proxy: {
"/proxy/": {
target: "https://wid.cert-bund.de/",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy\//, "")
}
}
},
plugins: [sveltekit()],
test: {
include: ["src/**/*.{test,spec}.{js,ts}"],
coverage: {
provider: "istanbul",
reporter: ["text", "json-summary", "json", "html"],
lines: 60,
branches: 60,
functions: 60,
statements: 60
}
},
define: {
__APP_VERSION__: JSON.stringify(getSemverVersion())
}
});