Skip to content

Commit 490eb71

Browse files
committed
v2.4.0 (#19)
2 parents a9e4d21 + af2cce9 commit 490eb71

8 files changed

Lines changed: 143 additions & 48 deletions

File tree

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,99 @@
1-
# Simple workflow for deploying static content to GitHub Pages
2-
name: Deploy static content to Pages
1+
name: Deploy to GitHub Pages
32

43
on:
5-
# Runs on pushes targeting the default branch
64
push:
75
branches: ['main']
8-
9-
# Allows you to run this workflow manually from the Actions tab
106
workflow_dispatch:
117

12-
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
138
permissions:
149
contents: read
15-
pages: write
16-
id-token: write
1710

18-
# Allow one concurrent deployment
1911
concurrency:
2012
group: 'pages'
21-
cancel-in-progress: true
13+
cancel-in-progress: false
2214

2315
jobs:
24-
# Single deploy job since we're just deploying
25-
deploy:
26-
environment:
27-
name: github-pages
28-
url: ${{ steps.deployment.outputs.page_url }}
16+
build:
2917
runs-on: ubuntu-latest
3018
steps:
3119
- name: Checkout
32-
uses: actions/checkout@v5
20+
uses: actions/checkout@v4
21+
3322
- name: Set up Node
3423
uses: actions/setup-node@v4
3524
with:
3625
node-version: lts/*
3726
cache: 'npm'
27+
3828
- name: Install dependencies
3929
run: npm ci
30+
31+
- name: Lint
32+
run: npm run lint
33+
4034
- name: Build
4135
run: npm run build
42-
- name: Setup Pages
43-
uses: actions/configure-pages@v5
36+
4437
- name: Upload artifact
4538
uses: actions/upload-pages-artifact@v4
4639
with:
47-
# Upload dist folder
4840
path: './dist'
41+
42+
deploy:
43+
needs: build
44+
runs-on: ubuntu-latest
45+
permissions:
46+
pages: write
47+
id-token: write
48+
environment:
49+
name: github-pages
50+
url: ${{ steps.deployment.outputs.page_url }}
51+
steps:
52+
- name: Configure Pages
53+
uses: actions/configure-pages@v4
54+
4955
- name: Deploy to GitHub Pages
5056
id: deployment
5157
uses: actions/deploy-pages@v4
58+
59+
release:
60+
needs: deploy
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: write
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Get version from package.json
71+
id: version
72+
run: |
73+
VERSION=$(node -p "require('./package.json').version")
74+
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
75+
76+
- name: Check if tag already exists
77+
id: check_tag
78+
run: |
79+
if git rev-parse "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
80+
echo "exists=true" >> "$GITHUB_OUTPUT"
81+
else
82+
echo "exists=false" >> "$GITHUB_OUTPUT"
83+
fi
84+
85+
- name: Extract changelog for version
86+
if: steps.check_tag.outputs.exists == 'false'
87+
run: |
88+
TAG="${{ steps.version.outputs.tag }}"
89+
awk "/^## \\[${TAG}\\]/{found=1; next} found && /^## \\[v/{exit} found{print}" CHANGELOG.md > release_body.md
90+
91+
- name: Create GitHub release
92+
if: steps.check_tag.outputs.exists == 'false'
93+
env:
94+
GH_TOKEN: ${{ github.token }}
95+
run: |
96+
gh release create "${{ steps.version.outputs.tag }}" \
97+
--title "${{ steps.version.outputs.tag }}" \
98+
--notes-file release_body.md \
99+
--target "${{ github.sha }}"

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,34 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased](https://github.com/Synogun/GraphVM/compare/v2.3.0...develop)
8+
## [Unreleased](https://github.com/Synogun/GraphVM/compare/v2.4.0...develop)
99

1010
### Added
1111

1212
### Changed
1313

1414
### Fixed
1515

16+
## [v2.4.0](https://github.com/Synogun/GraphVM/compare/v2.3.0...v2.4.0)
17+
18+
### Added
19+
20+
- `Actions` - Added a release step for the project's pipeline.
21+
- `GraphService` - Added a `resetGraph` function to clear the current graph data and state.
22+
23+
### Changed
24+
25+
- `Algorithms` - Adjusted graph generation algorithms to use `resetGraph` instead of `clearGraph` for better state management.
26+
27+
### Fixed
28+
29+
- `Logger` - Fixed logs being stored in production.
30+
- `Actions` - Fixed deployment failing but deploying anyway.
31+
32+
### Removed
33+
34+
- `EdgeService` - Removed dead property `numEdges` from the graph's data.
35+
1636
## [v2.3.0](https://github.com/Synogun/GraphVM/compare/v2.0.0...v2.3.0)
1737

1838
### Added

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "graphvm",
33
"private": true,
4-
"version": "2.3.0",
4+
"version": "2.4.0",
55
"type": "module",
66
"author": "Synogun",
77
"license": "MIT",
@@ -11,7 +11,7 @@
1111
"update-u": "npx ncu --format group -u",
1212
"dev": "vite",
1313
"dev:host": "vite --host",
14-
"pre:build": "npm run lint",
14+
"prebuild": "npm run lint",
1515
"build": "tsc -b && vite build",
1616
"lint": "eslint ./src --fix",
1717
"format": "prettier --write \"src/**/*\"",

src/config/logger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export const Logger = {
4747
* @param args - additional arguments to include in the log
4848
*/
4949
_store: (level: string, context: string, message: string, args: unknown[]) => {
50+
if (import.meta.env.PROD) {
51+
return;
52+
}
53+
5054
const timestamp = new Date().toISOString();
5155
const argsStr = args
5256
.map((arg) => {

src/hooks/useActionBarLogic.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useGetGraph } from '@/hooks/useGraphRegistry';
33
import { addEdges, removeEdges } from '@/services/edgesService';
44
import { arrangeGraph, centerGraph } from '@/services/layoutService';
55
import { addNode, removeNodes } from '@/services/nodesService';
6+
import { resetGraph } from '@/services/graphService';
67
import { isArrayOfStrings } from '@/types/typeGuards';
78
import {
89
useGraphProperties,
@@ -58,15 +59,13 @@ export function useActionBarLogic() {
5859
return;
5960
}
6061

61-
graph.elements().remove();
62-
graph.data('directed', false);
63-
setNodeCount(0);
64-
setEdgeCount(0);
65-
setSelectedNodes([]);
66-
setSelectedEdges([]);
67-
graph.data('nodeSelectionOrder', []);
68-
graph.data('edgeSelectionOrder', []);
69-
setDirected(false);
62+
resetGraph(graph, {
63+
setNodeCount,
64+
setEdgeCount,
65+
setSelectedNodes,
66+
setSelectedEdges,
67+
setDirected,
68+
});
7069
}, [
7170
graphRef,
7271
setDirected,

src/services/algorithms/generationAlgorithmsService.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
} from '@/types/algorithms';
2222
import type cytoscape from 'cytoscape';
2323
import { addEdge, addEdges } from '../edgesService';
24+
import { resetGraph } from '../graphService';
2425
import { arrangeGraph } from '../layoutService';
2526
import { addNode } from '../nodesService';
2627

@@ -38,7 +39,7 @@ export function generateCompleteGraph(
3839
);
3940
}
4041

41-
clearGraph(graph);
42+
resetGraph(graph);
4243

4344
// Add nodes
4445
for (let i = 0; i < nodeCount; i++) {
@@ -76,7 +77,7 @@ export function generateGridGraph(
7677
);
7778
}
7879

79-
clearGraph(graph);
80+
resetGraph(graph);
8081

8182
const totalNodes = rows * cols;
8283

@@ -137,7 +138,7 @@ export function generateCircleGraph(
137138
);
138139
}
139140

140-
clearGraph(graph);
141+
resetGraph(graph);
141142

142143
// Add nodes
143144
for (let i = 0; i < nodeCount; i++) {
@@ -178,7 +179,7 @@ export function generateStarGraph(
178179
}
179180

180181
// Clear existing graph
181-
clearGraph(graph);
182+
resetGraph(graph);
182183

183184
// Add central node
184185
const centerNode = addNode(graph);
@@ -215,7 +216,7 @@ export function generateWheelGraph(
215216
);
216217
}
217218

218-
clearGraph(graph);
219+
resetGraph(graph);
219220

220221
// Connect outer nodes to center
221222
const centerNode = addNode(graph);
@@ -268,7 +269,7 @@ export function generateBipartiteGraph(
268269
);
269270
}
270271

271-
clearGraph(graph);
272+
resetGraph(graph);
272273

273274
// Add nodes for set A
274275
const setANodes: cytoscape.NodeSingular[] = [];
@@ -319,7 +320,7 @@ export function generateCompleteBipartiteGraph(
319320
);
320321
}
321322

322-
clearGraph(graph);
323+
resetGraph(graph);
323324

324325
// Add nodes for set A
325326
const setANodes: cytoscape.NodeSingular[] = [];
@@ -369,7 +370,7 @@ export function generateSimpleGraph(
369370
);
370371
}
371372

372-
clearGraph(graph);
373+
resetGraph(graph);
373374

374375
// Add nodes
375376
for (let i = 0; i < nodeCount; i++) {
@@ -406,10 +407,3 @@ export function generateSimpleGraph(
406407
arrangeGraph(graph, layout);
407408
}
408409
}
409-
410-
function clearGraph(graph: cytoscape.Core) {
411-
graph.elements().remove();
412-
graph.data('directed', false);
413-
graph.data('nodeSelectionOrder', []);
414-
graph.data('edgeSelectionOrder', []);
415-
}

src/services/edgesService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ export function addEdge(
4747
if (isDirected) {
4848
core.$id(newId).addClass('directed');
4949
}
50-
51-
core.data('numEdges', core.edges().length);
5250
}
5351

5452
export function addEdges(

src/services/graphService.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@ import {
33
DefaultGraphOptions,
44
DefaultNodesData,
55
} from '@/constants/graphDefaults';
6+
import { Logger } from '@Logger';
67
import cytoscape from 'cytoscape';
78

9+
const logger = Logger.createContextLogger('GraphService');
10+
11+
type ResetGraphState = {
12+
setNodeCount?: (count: number) => void;
13+
setEdgeCount?: (count: number) => void;
14+
setSelectedNodes?: (nodes: string[]) => void;
15+
setSelectedEdges?: (edges: string[]) => void;
16+
setDirected?: (directed: boolean) => void;
17+
};
18+
819
export function setGraphDirected(
920
core: cytoscape.Core,
1021
directed: boolean,
@@ -23,6 +34,27 @@ export function setGraphDirected(
2334
}
2435
}
2536

37+
export function resetGraph(
38+
core: cytoscape.Core,
39+
reactState?: ResetGraphState
40+
): void {
41+
logger.info('Resetting graph');
42+
43+
core.elements().remove();
44+
core.data('directed', false);
45+
core.data('nodeSelectionOrder', []);
46+
core.data('edgeSelectionOrder', []);
47+
48+
const nodeCount = core.nodes().length;
49+
const edgeCount = core.edges().length;
50+
51+
reactState?.setNodeCount?.(nodeCount);
52+
reactState?.setEdgeCount?.(edgeCount);
53+
reactState?.setSelectedNodes?.([]);
54+
reactState?.setSelectedEdges?.([]);
55+
reactState?.setDirected?.(false);
56+
}
57+
2658
export function newGraph(
2759
containerId?: string,
2860
options?: cytoscape.CytoscapeOptions

0 commit comments

Comments
 (0)