feat: add changelog to sidebar
Some checks failed
🚀 Lint & Test & Deploy / release (push) Failing after 4m36s
Some checks failed
🚀 Lint & Test & Deploy / release (push) Failing after 4m36s
This commit is contained in:
79
app/src/lib/sidebar/panels/Changelog.svelte
Normal file
79
app/src/lib/sidebar/panels/Changelog.svelte
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
type Change = { type: string; content: string };
|
||||||
|
|
||||||
|
async function fetchChangelog() {
|
||||||
|
const res = await fetch('/CHANGELOG.md');
|
||||||
|
return await res.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
const typeMap: Record<string, string> = {
|
||||||
|
fix: 'bg-layer-2 bg-red-800',
|
||||||
|
feat: 'bg-layer-2 bg-green-800',
|
||||||
|
chore: 'bg-layer-2 bg-gray-800',
|
||||||
|
docs: 'bg-layer-2 bg-blue-800',
|
||||||
|
refactor: 'bg-layer-2 bg-purple-800',
|
||||||
|
default: 'bg-layer-2 text-text'
|
||||||
|
};
|
||||||
|
|
||||||
|
function parseChangelog(md: string) {
|
||||||
|
const lines = md.split('\n');
|
||||||
|
const parsed: (string | Change)[] = [];
|
||||||
|
|
||||||
|
for (let line of lines) {
|
||||||
|
line = line.trim();
|
||||||
|
if (!line) continue;
|
||||||
|
|
||||||
|
if (line === '---') {
|
||||||
|
parsed.push({ type: 'hr', content: '' });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Headers
|
||||||
|
if (line.startsWith('## ')) {
|
||||||
|
parsed.push(line.replace('## ', ''));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit type
|
||||||
|
const match = line.match(/^(fix|feat|chore|docs|refactor)(\(|:)/i);
|
||||||
|
if (match) {
|
||||||
|
parsed.push({ type: match[1].toLowerCase(), content: line });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other lines
|
||||||
|
parsed.push({ type: 'default', content: line });
|
||||||
|
}
|
||||||
|
|
||||||
|
let lastLine = parsed.at(-1);
|
||||||
|
if (lastLine !== undefined && typeof lastLine !== 'string' && lastLine.type === 'hr') {
|
||||||
|
parsed.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="p-4 font-mono text-text">
|
||||||
|
{#await fetchChangelog()}
|
||||||
|
<p>Loading...</p>
|
||||||
|
{:then md}
|
||||||
|
{#each parseChangelog(md) as item (item)}
|
||||||
|
{#if typeof item === 'string'}
|
||||||
|
<h2 class="text-xl font-semibold mt-4 mb-4 text-layer-1">{item}</h2>
|
||||||
|
{:else if item.type === 'hr'}
|
||||||
|
<p></p>
|
||||||
|
{:else}
|
||||||
|
<p class="px-3 py-1 mb-1 leading-8 border-b-1 border-b-outline last:border-b-0">
|
||||||
|
{#if item.type !== 'default'}
|
||||||
|
<span class="p-1 rounded-sm font-semibold {typeMap[item.type]}">
|
||||||
|
{item.content.split(':')[0]}
|
||||||
|
</span> {item.content.split(':').slice(1).join(':').trim()}
|
||||||
|
{:else}
|
||||||
|
{item.content}
|
||||||
|
{/if}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{/await}
|
||||||
|
</div>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
import Panel from '$lib/sidebar/Panel.svelte';
|
import Panel from '$lib/sidebar/Panel.svelte';
|
||||||
import ActiveNodeSettings from '$lib/sidebar/panels/ActiveNodeSettings.svelte';
|
import ActiveNodeSettings from '$lib/sidebar/panels/ActiveNodeSettings.svelte';
|
||||||
import BenchmarkPanel from '$lib/sidebar/panels/BenchmarkPanel.svelte';
|
import BenchmarkPanel from '$lib/sidebar/panels/BenchmarkPanel.svelte';
|
||||||
|
import Changelog from '$lib/sidebar/panels/Changelog.svelte';
|
||||||
import ExportSettings from '$lib/sidebar/panels/ExportSettings.svelte';
|
import ExportSettings from '$lib/sidebar/panels/ExportSettings.svelte';
|
||||||
import GraphSource from '$lib/sidebar/panels/GraphSource.svelte';
|
import GraphSource from '$lib/sidebar/panels/GraphSource.svelte';
|
||||||
import Keymap from '$lib/sidebar/panels/Keymap.svelte';
|
import Keymap from '$lib/sidebar/panels/Keymap.svelte';
|
||||||
@@ -249,6 +250,13 @@
|
|||||||
/>
|
/>
|
||||||
<ActiveNodeSettings {manager} bind:node={activeNode} />
|
<ActiveNodeSettings {manager} bind:node={activeNode} />
|
||||||
</Panel>
|
</Panel>
|
||||||
|
<Panel
|
||||||
|
id="changelog"
|
||||||
|
title="Changelog"
|
||||||
|
icon="i-[tabler--file-text-spark] bg-green-400"
|
||||||
|
>
|
||||||
|
<Changelog />
|
||||||
|
</Panel>
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
</Grid.Cell>
|
</Grid.Cell>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
|
|||||||
1
app/static/.gitignore
vendored
1
app/static/.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
nodes/
|
nodes/
|
||||||
|
CHANGELOG.md
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"build:story": "pnpm -r --filter 'ui' story:build",
|
"build:story": "pnpm -r --filter 'ui' story:build",
|
||||||
"build:app": "BASE_PATH=/ui pnpm -r --filter 'ui' build && pnpm -r --filter 'app' build",
|
"build:app": "BASE_PATH=/ui pnpm -r --filter 'ui' build && pnpm -r --filter 'app' build",
|
||||||
"build:nodes": "cargo build --workspace --target wasm32-unknown-unknown --release && rm -rf ./app/static/nodes/max/plantarium/ && mkdir -p ./app/static/nodes/max/plantarium/ && cp -R ./target/wasm32-unknown-unknown/release/*.wasm ./app/static/nodes/max/plantarium/",
|
"build:nodes": "cargo build --workspace --target wasm32-unknown-unknown --release && rm -rf ./app/static/nodes/max/plantarium/ && mkdir -p ./app/static/nodes/max/plantarium/ && cp -R ./target/wasm32-unknown-unknown/release/*.wasm ./app/static/nodes/max/plantarium/",
|
||||||
"build:deploy": "pnpm build && cp -R packages/ui/build app/build/ui",
|
"build:deploy": "cp CHANGELOG.md app/static/CHANGELOG.md && pnpm build && cp -R packages/ui/build app/build/ui",
|
||||||
"dev:nodes": "chokidar './nodes/**' --initial -i '/pkg/' -c 'pnpm build:nodes'",
|
"dev:nodes": "chokidar './nodes/**' --initial -i '/pkg/' -c 'pnpm build:nodes'",
|
||||||
"dev:app_ui": "pnpm -r --parallel --filter 'app' --filter './packages/ui' dev",
|
"dev:app_ui": "pnpm -r --parallel --filter 'app' --filter './packages/ui' dev",
|
||||||
"dev_ui": "pnpm -r --filter 'ui' dev:ui",
|
"dev_ui": "pnpm -r --filter 'ui' dev:ui",
|
||||||
|
|||||||
Reference in New Issue
Block a user