@virmator/frontend 13.0.2 → 13.0.3
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/configs/c8.config.json +20 -0
- package/configs/typedoc.config.ts +25 -0
- package/configs/vite.config.base.ts +123 -0
- package/configs/vite.config.ts +14 -0
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"100": true,
|
|
3
|
+
"all": true,
|
|
4
|
+
"checkCoverage": true,
|
|
5
|
+
"clean": true,
|
|
6
|
+
"exclude": [
|
|
7
|
+
"**/*.test.ts",
|
|
8
|
+
"**/*.example.ts",
|
|
9
|
+
"**/*.test-helper.ts"
|
|
10
|
+
],
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.ts"
|
|
13
|
+
],
|
|
14
|
+
"perFile": true,
|
|
15
|
+
"reporter": [
|
|
16
|
+
"html",
|
|
17
|
+
"istanbul-smart-text-reporter"
|
|
18
|
+
],
|
|
19
|
+
"skipFull": true
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {baseTypedocConfig} from '@virmator/docs/configs/typedoc.config.base';
|
|
2
|
+
import {join, resolve} from 'path';
|
|
3
|
+
import type {TypeDocOptions} from 'typedoc';
|
|
4
|
+
|
|
5
|
+
const repoRoot = resolve(
|
|
6
|
+
__dirname,
|
|
7
|
+
/** Go up two directories because this gets compiled into `node_modules/.virmator` */
|
|
8
|
+
'..',
|
|
9
|
+
'..',
|
|
10
|
+
);
|
|
11
|
+
const indexTsFile = join(repoRoot, 'src', 'frontend.ts');
|
|
12
|
+
|
|
13
|
+
export const typeDocConfig: Partial<TypeDocOptions> = {
|
|
14
|
+
...baseTypedocConfig,
|
|
15
|
+
out: join(repoRoot, 'dist-docs'),
|
|
16
|
+
entryPoints: [
|
|
17
|
+
indexTsFile,
|
|
18
|
+
],
|
|
19
|
+
intentionallyNotExported: [],
|
|
20
|
+
defaultCategory: 'MISSING CATEGORY',
|
|
21
|
+
categoryOrder: [
|
|
22
|
+
'Main',
|
|
23
|
+
'Internal',
|
|
24
|
+
],
|
|
25
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {log, logColors} from '@augment-vir/node-js';
|
|
2
|
+
import {alwaysReloadPlugin} from '@virmator/frontend/src/always-reload.vite';
|
|
3
|
+
import {existsSync} from 'node:fs';
|
|
4
|
+
import {basename, dirname, join, relative} from 'node:path';
|
|
5
|
+
import type {UserConfig, UserConfigExport} from 'vite';
|
|
6
|
+
|
|
7
|
+
export const basePlugins = [
|
|
8
|
+
alwaysReloadPlugin(),
|
|
9
|
+
] as const;
|
|
10
|
+
|
|
11
|
+
export function findGitRepoRoot(dir: string): string {
|
|
12
|
+
if (existsSync(join(dir, '.git'))) {
|
|
13
|
+
return dir;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const nextDir = dirname(dir);
|
|
17
|
+
|
|
18
|
+
if (nextDir === dir) {
|
|
19
|
+
// failed to find an ancestor dir with a .git folder
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return findGitRepoRoot(nextDir);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type BaseConfigOptions = {
|
|
27
|
+
/** If your prod deploy is going to be GitHub pages, set this to true. */
|
|
28
|
+
forGitHubPages: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Path to the package directory that owns this vite config. Should most likely be left empty or
|
|
31
|
+
* set to resolve(__dirname, '..').
|
|
32
|
+
*/
|
|
33
|
+
packageDirPath?: string;
|
|
34
|
+
/** Disables printing of server directory paths. */
|
|
35
|
+
disableStartupLogs?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type ConfigPaths = {
|
|
39
|
+
srcDir: string;
|
|
40
|
+
staticDir: string;
|
|
41
|
+
outDir: string;
|
|
42
|
+
cwd: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type OverrideCallback = (
|
|
46
|
+
baseConfig: Readonly<UserConfig>,
|
|
47
|
+
basePaths: Readonly<ConfigPaths>,
|
|
48
|
+
) => UserConfig | Promise<UserConfig>;
|
|
49
|
+
|
|
50
|
+
export function createBaseConfig({forGitHubPages, packageDirPath}: BaseConfigOptions): {
|
|
51
|
+
baseConfig: UserConfig;
|
|
52
|
+
basePaths: ConfigPaths;
|
|
53
|
+
} {
|
|
54
|
+
const cwd = packageDirPath || process.cwd();
|
|
55
|
+
|
|
56
|
+
const basePath: string =
|
|
57
|
+
forGitHubPages && process.env.CI ? `/${basename(findGitRepoRoot(cwd))}` : '/';
|
|
58
|
+
|
|
59
|
+
const srcDir = join(cwd, 'src');
|
|
60
|
+
const staticDir = join(cwd, 'www-static');
|
|
61
|
+
const outDir = join(cwd, 'dist');
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
baseConfig: {
|
|
65
|
+
clearScreen: false,
|
|
66
|
+
base: basePath,
|
|
67
|
+
publicDir: staticDir,
|
|
68
|
+
root: srcDir,
|
|
69
|
+
plugins: [
|
|
70
|
+
...basePlugins,
|
|
71
|
+
],
|
|
72
|
+
build: {
|
|
73
|
+
outDir,
|
|
74
|
+
emptyOutDir: true,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
basePaths: {
|
|
78
|
+
cwd,
|
|
79
|
+
outDir,
|
|
80
|
+
srcDir,
|
|
81
|
+
staticDir,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function combineConfigs(
|
|
87
|
+
baseConfigOptions: BaseConfigOptions,
|
|
88
|
+
overrideCallback: OverrideCallback | undefined,
|
|
89
|
+
): Promise<UserConfig> {
|
|
90
|
+
const {baseConfig, basePaths} = createBaseConfig(baseConfigOptions);
|
|
91
|
+
const fullConfig = overrideCallback
|
|
92
|
+
? await overrideCallback(baseConfig, basePaths)
|
|
93
|
+
: baseConfig;
|
|
94
|
+
|
|
95
|
+
if (!baseConfigOptions.disableStartupLogs) {
|
|
96
|
+
log.faint(
|
|
97
|
+
`public dir: ${logColors.info}${relative(process.cwd(), fullConfig.publicDir || '')}${
|
|
98
|
+
logColors.reset
|
|
99
|
+
}`,
|
|
100
|
+
);
|
|
101
|
+
log.faint(
|
|
102
|
+
`root dir: ${logColors.info}${relative(process.cwd(), fullConfig.root || '')}${
|
|
103
|
+
logColors.reset
|
|
104
|
+
}`,
|
|
105
|
+
);
|
|
106
|
+
log.faint(
|
|
107
|
+
`out dir: ${logColors.info}${relative(
|
|
108
|
+
process.cwd(),
|
|
109
|
+
fullConfig.build?.outDir || '',
|
|
110
|
+
)}${logColors.reset}`,
|
|
111
|
+
);
|
|
112
|
+
log.faint(`base path: ${logColors.info}${fullConfig.base}${logColors.reset}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return fullConfig;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function defineConfig(
|
|
119
|
+
baseConfigOptions: BaseConfigOptions,
|
|
120
|
+
overrideCallback: OverrideCallback | undefined,
|
|
121
|
+
): UserConfigExport {
|
|
122
|
+
return combineConfigs(baseConfigOptions, overrideCallback);
|
|
123
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {defineConfig} from '@virmator/frontend/configs/vite.config.base.ts';
|
|
2
|
+
import {resolve} from 'node:path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig(
|
|
5
|
+
{
|
|
6
|
+
forGitHubPages: true,
|
|
7
|
+
packageDirPath: resolve(import.meta.dirname, '..'),
|
|
8
|
+
},
|
|
9
|
+
(baseConfig) => {
|
|
10
|
+
return {
|
|
11
|
+
...baseConfig,
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/frontend",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.3",
|
|
4
4
|
"description": "Default frontend plugin for virmator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"virmator",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@augment-vir/common": "^29.3.0",
|
|
38
38
|
"@augment-vir/node-js": "^29.3.0",
|
|
39
|
-
"@virmator/core": "^13.0.
|
|
39
|
+
"@virmator/core": "^13.0.3",
|
|
40
40
|
"mri": "^1.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|