Skip to content

Commit

Permalink
feat: display app version in Settings (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaclen authored Jul 22, 2024
1 parent 50d9769 commit 04dce63
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

- name: Update package.json
run: node .github/workflows/publish/update-package-json.js ${{ steps.semantic.outputs.new_release_version }}

docker:
needs: release
if: ${{ needs.release.outputs.new_release_published == 'true' }}
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/publish/update-package-json.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Usage:
// node .github/workflows/publish/update-package-json.js 4.2.0

const fs = require('fs');
const version = process.argv[2]; // Get version from command line argument

// Read package.json
fs.readFile('package.json', (err, data) => {
if (err) throw err;

let json = JSON.parse(data);

// Update version field
json.version = version;

// Write updated package.json
fs.writeFile('package.json', JSON.stringify(json, null, 2), (err) => {
if (err) throw err;
console.log('Package.json file has been updated');
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hollama",
"version": "0.0.1",
"version": "0.0.0-dev",
"private": true,
"scripts": {
"dev": "vite dev --host",
Expand Down
13 changes: 12 additions & 1 deletion src/routes/settings/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { onMount } from 'svelte';
import { version } from '$app/environment';
import Badge from '$lib/components/Badge.svelte';
import Button from '$lib/components/Button.svelte';
Expand Down Expand Up @@ -163,6 +164,11 @@
</Button>
</p>
</div>
<div class="version">
<p class="p">
<strong>Version</strong> <Button variant="link" href="https://github.com/fmaclen/hollama/releases" target="_blank">{version}</Button>
</p>
</div>
</div>
</section>

Expand All @@ -178,11 +184,16 @@
@apply flex flex-col gap-y-4 my-auto;
}
.about {
.about,
.version {
@apply container mx-auto flex max-w-[80ch] flex-col gap-y-2 p-4;
@apply lg:p-6;
}
.version {
@apply last:py-0 last:text-muted;
}
.code {
@apply rounded-md p-1 text-active;
}
Expand Down
5 changes: 4 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const config = {
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: process.env.ADAPTER === 'docker-node' ?
adapterNode(adapterConfig) :
adapterCloudflare(adapterConfig)
adapterCloudflare(adapterConfig),
version: {
name: process.env.npm_package_version
}
}
};

Expand Down
Binary file modified tests/docs.test.ts-snapshots/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 04dce63

Please sign in to comment.