@bevel-software/platform-core-frontend 0.4.0 → 0.4.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/package.json +2 -2
- package/src/core/__tests__/ShellRoutes.test.tsx +95 -95
- package/src/lib/utils.ts +138 -138
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +156 -156
- package/src/modules/admin/components/UserAccountsPage.tsx +353 -353
- package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -104
- package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -200
- package/src/modules/library/__tests__/loadout.test.tsx +72 -72
- package/src/modules/library/__tests__/status.test.ts +117 -117
- package/src/modules/library/components/ChangeRequestDock.tsx +47 -47
- package/src/modules/library/components/CompareView.tsx +357 -357
- package/src/modules/library/components/DetailDialog.tsx +566 -566
- package/src/modules/library/components/GearIcon.tsx +12 -12
- package/src/modules/library/components/LibraryCard.tsx +132 -132
- package/src/modules/library/components/LibraryPage.tsx +254 -254
- package/src/modules/library/components/LoadoutSidebar.tsx +156 -156
- package/src/modules/library/components/StatusGem.tsx +21 -21
- package/src/modules/library/components/SuggestChange.tsx +171 -171
- package/src/modules/library/components/particles.ts +50 -50
- package/src/modules/library/library.css +320 -320
- package/src/modules/library/state/loadout.tsx +129 -129
- package/src/modules/library/utils/status.ts +116 -116
- package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -276
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -51
- package/src/modules/toolbar/components/AppSwitcher.tsx +108 -108
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
- package/src/modules/workspace/components/FileExplorer.tsx +1068 -1068
- package/src/modules/workspace/components/FileViewer.tsx +906 -906
- package/src/modules/workspace/utils/fileTree.ts +179 -179
- package/src/shared/components/PageShell.tsx +51 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevel-software/platform-core-frontend",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Open-source core UI of the Bevel platform (raw TS/TSX source): workspace explorer/viewer, branches & change requests, Library, secrets, tools, access control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tailwind-merge": "^3.5.0",
|
|
39
39
|
"xlsx": "^0.18.5",
|
|
40
40
|
"yaml": "^2.9.0",
|
|
41
|
-
"@bevel-software/platform-shared": "0.4.
|
|
41
|
+
"@bevel-software/platform-shared": "0.4.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { MemoryRouter, useLocation } from 'react-router-dom';
|
|
4
|
-
import { ShellRoutes } from '../CoreAppShell';
|
|
5
|
-
import type { AppDef } from '../registry';
|
|
6
|
-
|
|
7
|
-
// The /secrets standalone page fetches on mount — stub its data layer so the
|
|
8
|
-
// route can render without a network. (The other standalone pages are not
|
|
9
|
-
// visited by these tests.)
|
|
10
|
-
vi.mock('../../modules/secrets-vault/services/secrets.api', () => ({
|
|
11
|
-
listSecrets: vi.fn(async () => []),
|
|
12
|
-
createOAuthSecret: vi.fn(async () => {}),
|
|
13
|
-
deleteSecret: vi.fn(async () => {}),
|
|
14
|
-
startOAuth: vi.fn(async () => ''),
|
|
15
|
-
}));
|
|
16
|
-
vi.mock('../../modules/secrets-vault/services/tool-secrets.api', () => ({
|
|
17
|
-
listToolSecrets: vi.fn(async () => []),
|
|
18
|
-
setAdminVar: vi.fn(async () => {}),
|
|
19
|
-
setUserVar: vi.fn(async () => {}),
|
|
20
|
-
setOAuthClientSecret: vi.fn(async () => {}),
|
|
21
|
-
deleteAdminVar: vi.fn(async () => {}),
|
|
22
|
-
deleteUserVar: vi.fn(async () => {}),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
/** Exposes the router's current pathname so redirects can be asserted. */
|
|
26
|
-
function LocationProbe() {
|
|
27
|
-
const location = useLocation();
|
|
28
|
-
return <div data-testid="pathname">{location.pathname}</div>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Stub app surfaces — the route table is what's under test, not the panes.
|
|
32
|
-
const apps: AppDef[] = [
|
|
33
|
-
{
|
|
34
|
-
id: 'knowledge',
|
|
35
|
-
label: 'Knowledge',
|
|
36
|
-
path: '/workspace',
|
|
37
|
-
order: 10,
|
|
38
|
-
element: <div data-testid="knowledge-surface" />,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: 'skills-tools',
|
|
42
|
-
label: 'Skills & Tools',
|
|
43
|
-
path: '/skills-and-tools',
|
|
44
|
-
order: 20,
|
|
45
|
-
element: <div data-testid="skills-surface" />,
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
function renderAt(path: string) {
|
|
50
|
-
return render(
|
|
51
|
-
<MemoryRouter initialEntries={[path]}>
|
|
52
|
-
<ShellRoutes apps={apps} />
|
|
53
|
-
<LocationProbe />
|
|
54
|
-
</MemoryRouter>,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
describe('ShellRoutes', () => {
|
|
59
|
-
it('redirects / to /workspace and renders the Knowledge surface', () => {
|
|
60
|
-
renderAt('/');
|
|
61
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
|
|
62
|
-
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('sends the retired /library path into the catch-all → /workspace', () => {
|
|
66
|
-
renderAt('/library');
|
|
67
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
|
|
68
|
-
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('sends an unknown URL into the catch-all → /workspace', () => {
|
|
72
|
-
renderAt('/no-such-page/at-all');
|
|
73
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
|
|
74
|
-
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('keeps a KB deep link inside the Knowledge surface', () => {
|
|
78
|
-
renderAt('/workspace/main/SomeFile.md');
|
|
79
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace/main/SomeFile.md');
|
|
80
|
-
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('renders the Skills & Tools surface at /skills-and-tools', () => {
|
|
84
|
-
renderAt('/skills-and-tools');
|
|
85
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/skills-and-tools$/);
|
|
86
|
-
expect(screen.getByTestId('skills-surface')).toBeInTheDocument();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('renders the standalone Secrets page at /secrets without redirecting', async () => {
|
|
90
|
-
renderAt('/secrets');
|
|
91
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/secrets$/);
|
|
92
|
-
expect(await screen.findByRole('heading', { name: 'Secrets' })).toBeInTheDocument();
|
|
93
|
-
expect(screen.queryByTestId('knowledge-surface')).not.toBeInTheDocument();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter, useLocation } from 'react-router-dom';
|
|
4
|
+
import { ShellRoutes } from '../CoreAppShell';
|
|
5
|
+
import type { AppDef } from '../registry';
|
|
6
|
+
|
|
7
|
+
// The /secrets standalone page fetches on mount — stub its data layer so the
|
|
8
|
+
// route can render without a network. (The other standalone pages are not
|
|
9
|
+
// visited by these tests.)
|
|
10
|
+
vi.mock('../../modules/secrets-vault/services/secrets.api', () => ({
|
|
11
|
+
listSecrets: vi.fn(async () => []),
|
|
12
|
+
createOAuthSecret: vi.fn(async () => {}),
|
|
13
|
+
deleteSecret: vi.fn(async () => {}),
|
|
14
|
+
startOAuth: vi.fn(async () => ''),
|
|
15
|
+
}));
|
|
16
|
+
vi.mock('../../modules/secrets-vault/services/tool-secrets.api', () => ({
|
|
17
|
+
listToolSecrets: vi.fn(async () => []),
|
|
18
|
+
setAdminVar: vi.fn(async () => {}),
|
|
19
|
+
setUserVar: vi.fn(async () => {}),
|
|
20
|
+
setOAuthClientSecret: vi.fn(async () => {}),
|
|
21
|
+
deleteAdminVar: vi.fn(async () => {}),
|
|
22
|
+
deleteUserVar: vi.fn(async () => {}),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
/** Exposes the router's current pathname so redirects can be asserted. */
|
|
26
|
+
function LocationProbe() {
|
|
27
|
+
const location = useLocation();
|
|
28
|
+
return <div data-testid="pathname">{location.pathname}</div>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Stub app surfaces — the route table is what's under test, not the panes.
|
|
32
|
+
const apps: AppDef[] = [
|
|
33
|
+
{
|
|
34
|
+
id: 'knowledge',
|
|
35
|
+
label: 'Knowledge',
|
|
36
|
+
path: '/workspace',
|
|
37
|
+
order: 10,
|
|
38
|
+
element: <div data-testid="knowledge-surface" />,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'skills-tools',
|
|
42
|
+
label: 'Skills & Tools',
|
|
43
|
+
path: '/skills-and-tools',
|
|
44
|
+
order: 20,
|
|
45
|
+
element: <div data-testid="skills-surface" />,
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
function renderAt(path: string) {
|
|
50
|
+
return render(
|
|
51
|
+
<MemoryRouter initialEntries={[path]}>
|
|
52
|
+
<ShellRoutes apps={apps} />
|
|
53
|
+
<LocationProbe />
|
|
54
|
+
</MemoryRouter>,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe('ShellRoutes', () => {
|
|
59
|
+
it('redirects / to /workspace and renders the Knowledge surface', () => {
|
|
60
|
+
renderAt('/');
|
|
61
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
|
|
62
|
+
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('sends the retired /library path into the catch-all → /workspace', () => {
|
|
66
|
+
renderAt('/library');
|
|
67
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
|
|
68
|
+
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('sends an unknown URL into the catch-all → /workspace', () => {
|
|
72
|
+
renderAt('/no-such-page/at-all');
|
|
73
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
|
|
74
|
+
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('keeps a KB deep link inside the Knowledge surface', () => {
|
|
78
|
+
renderAt('/workspace/main/SomeFile.md');
|
|
79
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace/main/SomeFile.md');
|
|
80
|
+
expect(screen.getByTestId('knowledge-surface')).toBeInTheDocument();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('renders the Skills & Tools surface at /skills-and-tools', () => {
|
|
84
|
+
renderAt('/skills-and-tools');
|
|
85
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/skills-and-tools$/);
|
|
86
|
+
expect(screen.getByTestId('skills-surface')).toBeInTheDocument();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('renders the standalone Secrets page at /secrets without redirecting', async () => {
|
|
90
|
+
renderAt('/secrets');
|
|
91
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/secrets$/);
|
|
92
|
+
expect(await screen.findByRole('heading', { name: 'Secrets' })).toBeInTheDocument();
|
|
93
|
+
expect(screen.queryByTestId('knowledge-surface')).not.toBeInTheDocument();
|
|
94
|
+
});
|
|
95
|
+
});
|
package/src/lib/utils.ts
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
import { clsx, type ClassValue } from 'clsx';
|
|
2
|
-
import { twMerge } from 'tailwind-merge';
|
|
3
|
-
|
|
4
|
-
export function cn(...inputs: ClassValue[]) {
|
|
5
|
-
return twMerge(clsx(inputs));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// Hide the extension in display labels. Dot-prefixed names (.env, .gitignore)
|
|
9
|
-
// keep their full name. Compound suffixes (foo.test.ts) only lose the final part.
|
|
10
|
-
export function stripExtension(filename: string): string {
|
|
11
|
-
const lastDot = filename.lastIndexOf('.');
|
|
12
|
-
if (lastDot <= 0) return filename;
|
|
13
|
-
return filename.slice(0, lastDot);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function getFileExtension(filename: string): string {
|
|
17
|
-
const lastDot = filename.lastIndexOf('.');
|
|
18
|
-
if (lastDot <= 0) return '';
|
|
19
|
-
return filename.slice(lastDot + 1).toLowerCase();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const ICON_BY_FILENAME: Record<string, string> = {
|
|
23
|
-
'package.json': 'nodejs',
|
|
24
|
-
'package-lock.json': 'nodejs',
|
|
25
|
-
'pnpm-lock.yaml': 'pnpm',
|
|
26
|
-
'pnpm-workspace.yaml': 'pnpm',
|
|
27
|
-
'yarn.lock': 'yarn',
|
|
28
|
-
'tsconfig.json': 'tsconfig',
|
|
29
|
-
'tsconfig.base.json': 'tsconfig',
|
|
30
|
-
'vite.config.ts': 'vite',
|
|
31
|
-
'vite.config.js': 'vite',
|
|
32
|
-
'vitest.config.ts': 'vitest',
|
|
33
|
-
'.gitignore': 'git',
|
|
34
|
-
'.gitattributes': 'git',
|
|
35
|
-
'.prettierrc': 'prettier',
|
|
36
|
-
'.prettierrc.json': 'prettier',
|
|
37
|
-
'.prettierignore': 'prettier',
|
|
38
|
-
'.eslintrc': 'eslint',
|
|
39
|
-
'.eslintrc.json': 'eslint',
|
|
40
|
-
'.eslintrc.js': 'eslint',
|
|
41
|
-
'eslint.config.js': 'eslint',
|
|
42
|
-
'eslint.config.ts': 'eslint',
|
|
43
|
-
dockerfile: 'docker',
|
|
44
|
-
'docker-compose.yml': 'docker',
|
|
45
|
-
'docker-compose.yaml': 'docker',
|
|
46
|
-
makefile: 'makefile',
|
|
47
|
-
'readme.md': 'readme',
|
|
48
|
-
readme: 'readme',
|
|
49
|
-
license: 'license',
|
|
50
|
-
'license.md': 'license',
|
|
51
|
-
'.env': 'tune',
|
|
52
|
-
'.env.local': 'tune',
|
|
53
|
-
'.env.production': 'tune',
|
|
54
|
-
'.env.development': 'tune',
|
|
55
|
-
'components.json': 'json',
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const ICON_BY_EXT: Record<string, string> = {
|
|
59
|
-
md: 'markdown',
|
|
60
|
-
mdx: 'markdown',
|
|
61
|
-
txt: 'document',
|
|
62
|
-
rtf: 'document',
|
|
63
|
-
pdf: 'pdf',
|
|
64
|
-
ts: 'typescript',
|
|
65
|
-
tsx: 'react-ts',
|
|
66
|
-
js: 'javascript',
|
|
67
|
-
jsx: 'react',
|
|
68
|
-
mjs: 'javascript',
|
|
69
|
-
cjs: 'javascript',
|
|
70
|
-
py: 'python',
|
|
71
|
-
rs: 'rust',
|
|
72
|
-
go: 'go',
|
|
73
|
-
rb: 'ruby',
|
|
74
|
-
java: 'java',
|
|
75
|
-
c: 'c',
|
|
76
|
-
cpp: 'cpp',
|
|
77
|
-
cs: 'csharp',
|
|
78
|
-
php: 'php',
|
|
79
|
-
swift: 'swift',
|
|
80
|
-
kt: 'kotlin',
|
|
81
|
-
sh: 'console',
|
|
82
|
-
bash: 'console',
|
|
83
|
-
zsh: 'console',
|
|
84
|
-
fish: 'console',
|
|
85
|
-
html: 'html',
|
|
86
|
-
htm: 'html',
|
|
87
|
-
css: 'css',
|
|
88
|
-
scss: 'scss',
|
|
89
|
-
sass: 'sass',
|
|
90
|
-
less: 'less',
|
|
91
|
-
json: 'json',
|
|
92
|
-
jsonc: 'json',
|
|
93
|
-
yml: 'yaml',
|
|
94
|
-
yaml: 'yaml',
|
|
95
|
-
toml: 'toml',
|
|
96
|
-
xml: 'xml',
|
|
97
|
-
csv: 'table',
|
|
98
|
-
tsv: 'table',
|
|
99
|
-
xls: 'table',
|
|
100
|
-
xlsx: 'table',
|
|
101
|
-
ods: 'table',
|
|
102
|
-
sql: 'database',
|
|
103
|
-
png: 'image',
|
|
104
|
-
jpg: 'image',
|
|
105
|
-
jpeg: 'image',
|
|
106
|
-
gif: 'image',
|
|
107
|
-
webp: 'image',
|
|
108
|
-
avif: 'image',
|
|
109
|
-
bmp: 'image',
|
|
110
|
-
ico: 'image',
|
|
111
|
-
svg: 'svg',
|
|
112
|
-
mp3: 'audio',
|
|
113
|
-
wav: 'audio',
|
|
114
|
-
flac: 'audio',
|
|
115
|
-
ogg: 'audio',
|
|
116
|
-
mp4: 'video',
|
|
117
|
-
mov: 'video',
|
|
118
|
-
webm: 'video',
|
|
119
|
-
avi: 'video',
|
|
120
|
-
zip: 'zip',
|
|
121
|
-
tar: 'zip',
|
|
122
|
-
gz: 'zip',
|
|
123
|
-
'7z': 'zip',
|
|
124
|
-
rar: 'zip',
|
|
125
|
-
ttf: 'font',
|
|
126
|
-
otf: 'font',
|
|
127
|
-
woff: 'font',
|
|
128
|
-
woff2: 'font',
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const DEFAULT_ICON = 'document';
|
|
132
|
-
|
|
133
|
-
export function getFileIcon(filename: string): string {
|
|
134
|
-
const lower = filename.toLowerCase();
|
|
135
|
-
const override = ICON_BY_FILENAME[lower];
|
|
136
|
-
if (override) return override;
|
|
137
|
-
return ICON_BY_EXT[getFileExtension(filename)] ?? DEFAULT_ICON;
|
|
138
|
-
}
|
|
1
|
+
import { clsx, type ClassValue } from 'clsx';
|
|
2
|
+
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs: ClassValue[]) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Hide the extension in display labels. Dot-prefixed names (.env, .gitignore)
|
|
9
|
+
// keep their full name. Compound suffixes (foo.test.ts) only lose the final part.
|
|
10
|
+
export function stripExtension(filename: string): string {
|
|
11
|
+
const lastDot = filename.lastIndexOf('.');
|
|
12
|
+
if (lastDot <= 0) return filename;
|
|
13
|
+
return filename.slice(0, lastDot);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getFileExtension(filename: string): string {
|
|
17
|
+
const lastDot = filename.lastIndexOf('.');
|
|
18
|
+
if (lastDot <= 0) return '';
|
|
19
|
+
return filename.slice(lastDot + 1).toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ICON_BY_FILENAME: Record<string, string> = {
|
|
23
|
+
'package.json': 'nodejs',
|
|
24
|
+
'package-lock.json': 'nodejs',
|
|
25
|
+
'pnpm-lock.yaml': 'pnpm',
|
|
26
|
+
'pnpm-workspace.yaml': 'pnpm',
|
|
27
|
+
'yarn.lock': 'yarn',
|
|
28
|
+
'tsconfig.json': 'tsconfig',
|
|
29
|
+
'tsconfig.base.json': 'tsconfig',
|
|
30
|
+
'vite.config.ts': 'vite',
|
|
31
|
+
'vite.config.js': 'vite',
|
|
32
|
+
'vitest.config.ts': 'vitest',
|
|
33
|
+
'.gitignore': 'git',
|
|
34
|
+
'.gitattributes': 'git',
|
|
35
|
+
'.prettierrc': 'prettier',
|
|
36
|
+
'.prettierrc.json': 'prettier',
|
|
37
|
+
'.prettierignore': 'prettier',
|
|
38
|
+
'.eslintrc': 'eslint',
|
|
39
|
+
'.eslintrc.json': 'eslint',
|
|
40
|
+
'.eslintrc.js': 'eslint',
|
|
41
|
+
'eslint.config.js': 'eslint',
|
|
42
|
+
'eslint.config.ts': 'eslint',
|
|
43
|
+
dockerfile: 'docker',
|
|
44
|
+
'docker-compose.yml': 'docker',
|
|
45
|
+
'docker-compose.yaml': 'docker',
|
|
46
|
+
makefile: 'makefile',
|
|
47
|
+
'readme.md': 'readme',
|
|
48
|
+
readme: 'readme',
|
|
49
|
+
license: 'license',
|
|
50
|
+
'license.md': 'license',
|
|
51
|
+
'.env': 'tune',
|
|
52
|
+
'.env.local': 'tune',
|
|
53
|
+
'.env.production': 'tune',
|
|
54
|
+
'.env.development': 'tune',
|
|
55
|
+
'components.json': 'json',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const ICON_BY_EXT: Record<string, string> = {
|
|
59
|
+
md: 'markdown',
|
|
60
|
+
mdx: 'markdown',
|
|
61
|
+
txt: 'document',
|
|
62
|
+
rtf: 'document',
|
|
63
|
+
pdf: 'pdf',
|
|
64
|
+
ts: 'typescript',
|
|
65
|
+
tsx: 'react-ts',
|
|
66
|
+
js: 'javascript',
|
|
67
|
+
jsx: 'react',
|
|
68
|
+
mjs: 'javascript',
|
|
69
|
+
cjs: 'javascript',
|
|
70
|
+
py: 'python',
|
|
71
|
+
rs: 'rust',
|
|
72
|
+
go: 'go',
|
|
73
|
+
rb: 'ruby',
|
|
74
|
+
java: 'java',
|
|
75
|
+
c: 'c',
|
|
76
|
+
cpp: 'cpp',
|
|
77
|
+
cs: 'csharp',
|
|
78
|
+
php: 'php',
|
|
79
|
+
swift: 'swift',
|
|
80
|
+
kt: 'kotlin',
|
|
81
|
+
sh: 'console',
|
|
82
|
+
bash: 'console',
|
|
83
|
+
zsh: 'console',
|
|
84
|
+
fish: 'console',
|
|
85
|
+
html: 'html',
|
|
86
|
+
htm: 'html',
|
|
87
|
+
css: 'css',
|
|
88
|
+
scss: 'scss',
|
|
89
|
+
sass: 'sass',
|
|
90
|
+
less: 'less',
|
|
91
|
+
json: 'json',
|
|
92
|
+
jsonc: 'json',
|
|
93
|
+
yml: 'yaml',
|
|
94
|
+
yaml: 'yaml',
|
|
95
|
+
toml: 'toml',
|
|
96
|
+
xml: 'xml',
|
|
97
|
+
csv: 'table',
|
|
98
|
+
tsv: 'table',
|
|
99
|
+
xls: 'table',
|
|
100
|
+
xlsx: 'table',
|
|
101
|
+
ods: 'table',
|
|
102
|
+
sql: 'database',
|
|
103
|
+
png: 'image',
|
|
104
|
+
jpg: 'image',
|
|
105
|
+
jpeg: 'image',
|
|
106
|
+
gif: 'image',
|
|
107
|
+
webp: 'image',
|
|
108
|
+
avif: 'image',
|
|
109
|
+
bmp: 'image',
|
|
110
|
+
ico: 'image',
|
|
111
|
+
svg: 'svg',
|
|
112
|
+
mp3: 'audio',
|
|
113
|
+
wav: 'audio',
|
|
114
|
+
flac: 'audio',
|
|
115
|
+
ogg: 'audio',
|
|
116
|
+
mp4: 'video',
|
|
117
|
+
mov: 'video',
|
|
118
|
+
webm: 'video',
|
|
119
|
+
avi: 'video',
|
|
120
|
+
zip: 'zip',
|
|
121
|
+
tar: 'zip',
|
|
122
|
+
gz: 'zip',
|
|
123
|
+
'7z': 'zip',
|
|
124
|
+
rar: 'zip',
|
|
125
|
+
ttf: 'font',
|
|
126
|
+
otf: 'font',
|
|
127
|
+
woff: 'font',
|
|
128
|
+
woff2: 'font',
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const DEFAULT_ICON = 'document';
|
|
132
|
+
|
|
133
|
+
export function getFileIcon(filename: string): string {
|
|
134
|
+
const lower = filename.toLowerCase();
|
|
135
|
+
const override = ICON_BY_FILENAME[lower];
|
|
136
|
+
if (override) return override;
|
|
137
|
+
return ICON_BY_EXT[getFileExtension(filename)] ?? DEFAULT_ICON;
|
|
138
|
+
}
|