Skip to content

Commit

Permalink
Merge branch 'thatmattlove:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
M0NsTeRRR authored Jun 1, 2024
2 parents 217529b + 7eb4f5c commit 733c449
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.0.1 - 2024-05-31

### Fixed
- [#244](https://github.com/thatmattlove/hyperglass/issues/244): Fix issue with UI build where UI build directory already existed and therefore could not be created.
- [#249](https://github.com/thatmattlove/hyperglass/issues/249): Fix issue where configuration values were improperly prepended with the `HYPERGLASS_APP_PATH` value.
- [#251](https://github.com/thatmattlove/hyperglass/issues/251): Fix issue where browser-based DNS resolution did not show, causing FQDN queries to fail due to validation.
- Fix issue where logo was improperly sized on small screens.

## 2.0.0 - 2024-05-28

_v2.0.0 is a major release of hyperglass. Many things have changed, and it is likely best to redeploy hyperglass in a new environment to migrate to v2._
Expand Down
2 changes: 1 addition & 1 deletion hyperglass/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime

__name__ = "hyperglass"
__version__ = "2.0.0"
__version__ = "2.0.1"
__author__ = "Matt Love"
__copyright__ = f"Copyright {datetime.now().year} Matthew Love"
__license__ = "BSD 3-Clause Clear License"
Expand Down
4 changes: 3 additions & 1 deletion hyperglass/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ async def build_ui(app_path: Path):
log.error(err)
raise RuntimeError(str(err)) from err

shutil.copytree(src=out_dir, dst=build_dir, dirs_exist_ok=True)
if build_dir.exists():
shutil.rmtree(build_dir)
shutil.copytree(src=out_dir, dst=build_dir, dirs_exist_ok=False)
log.bind(src=out_dir, dst=build_dir).debug("Migrated Next.JS build output")

return "\n".join(all_messages)
Expand Down
2 changes: 1 addition & 1 deletion hyperglass/models/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def convert_paths(self, value: t.Type[PathTypeT]) -> PathTypeT:
*(p for p in value.parts if p not in Settings.original_app_path.parts)
)

if isinstance(value, str):
if isinstance(value, str) and str(Settings.original_app_path) in value:
if Settings.container:
path = Path(value)
return str(
Expand Down
1 change: 0 additions & 1 deletion hyperglass/ui/components/header/title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const MWrapper = (props: MWrapperProps): JSX.Element => {
layout
spacing={1}
alignItems={formInteractive ? 'center' : 'flex-start'}
maxWidth="25%"
{...props}
/>
);
Expand Down
4 changes: 3 additions & 1 deletion hyperglass/ui/components/looking-glass-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export const LookingGlassForm = (): JSX.Element => {

const isFqdnQuery = useCallback(
(target: string | string[], fieldType: Directive['fieldType'] | null): boolean =>
typeof target === 'string' && fieldType === 'text' && isFQDN(target),
(typeof target === 'string' || Array.isArray(target)) &&
fieldType === 'text' &&
isFQDN(target),
[],
);

Expand Down
7 changes: 5 additions & 2 deletions hyperglass/ui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ const nextConfig = {
},
swcMinify: true,
productionBrowserSourceMaps: true,
output: 'export',
};

if (process.env.NODE_ENV === 'production') {
nextConfig.output = 'export';
}

if (process.env.NODE_ENV === 'development') {
nextConfig.rewrites = [
nextConfig.rewrites = async () => [
{ source: '/api/query', destination: `${process.env.HYPERGLASS_URL}api/query` },
{ source: '/images/:image*', destination: `${process.env.HYPERGLASS_URL}images/:image*` },
];
Expand Down
2 changes: 1 addition & 1 deletion hyperglass/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.0",
"version": "2.0.1",
"name": "ui",
"description": "UI for hyperglass, the modern network looking glass",
"author": "Matt Love",
Expand Down
13 changes: 5 additions & 8 deletions hyperglass/ui/util/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, describe, it, test } from 'vitest';
import { all, chunkArray, entries, dedupObjectArray, andJoin, isFQDN } from './common';
import { describe, expect, it, test } from 'vitest';
import { all, andJoin, chunkArray, dedupObjectArray, entries, isFQDN } from './common';

test('all - all items are truthy', () => {
// biome-ignore lint/suspicious/noSelfCompare: because this is a test, duh
Expand Down Expand Up @@ -79,12 +79,6 @@ describe('andJoin - join array of strings to sentence structure', () => {
});

describe('isFQDN - determine if a string is an FQDN pattern', () => {
it('is null and should be false', () => {
expect(isFQDN(null)).toBe(false);
});
it('is undefined and should be false', () => {
expect(isFQDN(undefined)).toBe(false);
});
it("isn't an FQDN and should be false", () => {
expect(isFQDN('example')).toBe(false);
});
Expand All @@ -100,4 +94,7 @@ describe('isFQDN - determine if a string is an FQDN pattern', () => {
it('is a longer FQDN and should be true', () => {
expect(isFQDN('one.two.three.four.five.example.com')).toBe(true);
});
it('is an array of FQDNs and should be true', () => {
expect(isFQDN(['www.example.com'])).toBe(true);
});
});
5 changes: 4 additions & 1 deletion hyperglass/ui/util/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function andJoin(values: string[], options?: AndJoinOptions): string {
*
* @param value Input value.
*/
export function isFQDN(value: unknown): value is string {
export function isFQDN(value: string | string[]): value is string {
/**
* Don't set the global flag on this.
* @see https://stackoverflow.com/questions/24084926/javascript-regexp-cant-use-twice
Expand All @@ -142,5 +142,8 @@ export function isFQDN(value: unknown): value is string {
const pattern = new RegExp(
/^(?!:\/\/)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-][a-zA-Z0-9-]+\.[a-zA-Z-]{2,6}?$/im,
);
if (Array.isArray(value)) {
return isFQDN(value[0]);
}
return typeof value === 'string' && pattern.test(value);
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hyperglass"
version = "2.0.0"
version = "2.0.1"
description = "hyperglass is the modern network looking glass that tries to make the internet better."
authors = [
{ name = "thatmattlove", email = "[email protected]" }
Expand Down

0 comments on commit 733c449

Please sign in to comment.