Skip to content

Commit 136a4a9

Browse files
authored
Merge pull request #27 from shiv3/feat/prettier-shiv3
feat: apply Prettier formatting across multiple files
2 parents 812bc11 + 17249a5 commit 136a4a9

23 files changed

+717
-519
lines changed

.github/workflows/manual-release.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version to release (e.g., 1.0.0)'
7+
description: "Version to release (e.g., 1.0.0)"
88
required: true
99
type: string
1010

@@ -17,7 +17,7 @@ jobs:
1717
release_id: ${{ steps.create_release.outputs.id }}
1818
steps:
1919
- uses: actions/checkout@v4
20-
20+
2121
- name: Create Release
2222
id: create_release
2323
uses: actions/github-script@v7
@@ -42,14 +42,14 @@ jobs:
4242
fail-fast: false
4343
matrix:
4444
include:
45-
- platform: 'macos-latest'
46-
args: '--target aarch64-apple-darwin'
47-
- platform: 'macos-latest'
48-
args: '--target x86_64-apple-darwin'
49-
- platform: 'ubuntu-22.04'
50-
args: ''
51-
- platform: 'windows-latest'
52-
args: ''
45+
- platform: "macos-latest"
46+
args: "--target aarch64-apple-darwin"
47+
- platform: "macos-latest"
48+
args: "--target x86_64-apple-darwin"
49+
- platform: "ubuntu-22.04"
50+
args: ""
51+
- platform: "windows-latest"
52+
args: ""
5353

5454
runs-on: ${{ matrix.platform }}
5555
steps:
@@ -80,4 +80,4 @@ jobs:
8080
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8181
with:
8282
releaseId: ${{ needs.create-release.outputs.release_id }}
83-
args: ${{ matrix.args }}
83+
args: ${{ matrix.args }}

.github/workflows/release.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release Desktop App
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- "v*"
77
workflow_dispatch:
88

99
jobs:
@@ -14,18 +14,18 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
include:
17-
- platform: 'macos-latest'
18-
args: '--target aarch64-apple-darwin'
19-
target: 'aarch64-apple-darwin'
20-
- platform: 'macos-latest'
21-
args: '--target x86_64-apple-darwin'
22-
target: 'x86_64-apple-darwin'
23-
- platform: 'ubuntu-22.04'
24-
args: ''
25-
target: 'x86_64-unknown-linux-gnu'
26-
- platform: 'windows-latest'
27-
args: ''
28-
target: 'x86_64-pc-windows-msvc'
17+
- platform: "macos-latest"
18+
args: "--target aarch64-apple-darwin"
19+
target: "aarch64-apple-darwin"
20+
- platform: "macos-latest"
21+
args: "--target x86_64-apple-darwin"
22+
target: "x86_64-apple-darwin"
23+
- platform: "ubuntu-22.04"
24+
args: ""
25+
target: "x86_64-unknown-linux-gnu"
26+
- platform: "windows-latest"
27+
args: ""
28+
target: "x86_64-pc-windows-msvc"
2929

3030
runs-on: ${{ matrix.platform }}
3131
steps:
@@ -61,18 +61,18 @@ jobs:
6161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6262
with:
6363
tagName: ${{ github.ref_name }}
64-
releaseName: 'OCPP CP Simulator ${{ github.ref_name }}'
64+
releaseName: "OCPP CP Simulator ${{ github.ref_name }}"
6565
releaseBody: |
6666
See the assets to download this version and install.
67-
67+
6868
## What's Changed
69-
69+
7070
### Desktop App Downloads
7171
- **macOS (Apple Silicon)**: `OCPP.CP.Simulator_*_aarch64.dmg`
7272
- **macOS (Intel)**: `OCPP.CP.Simulator_*_x64.dmg`
7373
- **Windows**: `OCPP.CP.Simulator_*_x64-setup.exe` or `.msi`
7474
- **Linux**: `ocpp-cp-simulator_*_amd64.AppImage` or `.deb`
75-
75+
7676
### Web Version
7777
The web version is available at: https://shiv3.github.io/ocpp-cp-simulator/
7878
releaseDraft: true
@@ -98,10 +98,10 @@ jobs:
9898
repo: context.repo.repo,
9999
tag: context.ref.replace('refs/tags/', '')
100100
});
101-
101+
102102
// Get commit history
103103
let body = release.body;
104-
104+
105105
try {
106106
const { data: commits } = await github.rest.repos.compareCommits({
107107
owner: context.repo.owner,
@@ -118,10 +118,10 @@ jobs:
118118
} catch (e) {
119119
console.log('Failed to get commit history:', e.message);
120120
}
121-
121+
122122
await github.rest.repos.updateRelease({
123123
owner: context.repo.owner,
124124
repo: context.repo.repo,
125125
release_id: release.id,
126126
body: body
127-
});
127+
});

.prettierignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Production build
5+
dist/
6+
build/
7+
8+
# Environment files
9+
.env
10+
.env.local
11+
.env.*.local
12+
13+
# Logs
14+
*.log
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*
18+
19+
# IDE
20+
.vscode/
21+
.idea/
22+
23+
# OS
24+
.DS_Store
25+
Thumbs.db
26+
27+
# Coverage
28+
coverage/
29+
30+
# Temporary files
31+
*.tmp
32+
*.temp
33+
34+
# Generated files
35+
*.min.js
36+
*.min.css
37+
38+
# Package manager files
39+
package-lock.json
40+
yarn.lock
41+
pnpm-lock.yaml
42+
43+
# Tauri generated files
44+
src-tauri/target/

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,51 @@
33
OCPP charger simulator written in React that works as a standalone web app or desktop application.
44

55
## Web Version
6+
67
https://shiv3.github.io/ocpp-cp-simulator/#config=%7B"wsURL"%3A"wss%3A%2F%2Flocalhost%3A8080%2F"%2C"connectorNumber"%3A2%2C"ChargePointID"%3A"test-cp"%2C"tagID"%3A"test-tag"%2C"ocppVersion"%3A"OCPP-1.6J"%2C"Experimental"%3Anull%7D
78

89
## Desktop Application
910

1011
### Download
12+
1113
Download the latest desktop version from the [Releases](https://github.com/shiv3/ocpp-cp-simulator/releases) page.
1214

1315
Available for:
14-
- **macOS**:
16+
17+
- **macOS**:
1518
- Apple Silicon: `OCPP.CP.Simulator_*_aarch64.dmg`
1619
- Intel: `OCPP.CP.Simulator_*_x64.dmg`
1720
- **Windows**: `OCPP.CP.Simulator_*_x64-setup.exe` or `.msi`
18-
- **Linux**:
21+
- **Linux**:
1922
- AppImage: `ocpp-cp-simulator_*_amd64.AppImage` (recommended)
2023
- Debian/Ubuntu: `ocpp-cp-simulator_*_amd64.deb`
2124

2225
### Installation
2326

2427
#### macOS
28+
2529
1. Download the appropriate `.dmg` file for your processor
2630
2. Open the downloaded file
2731
3. Drag the OCPP CP Simulator app to your Applications folder
2832
4. First time opening: Right-click and select "Open" to bypass Gatekeeper
2933

3034
#### Windows
35+
3136
1. Download the `.exe` or `.msi` installer
3237
2. Run the installer
3338
3. Follow the installation wizard
3439
4. The app will be available in your Start Menu
3540

3641
#### Linux
42+
3743
**AppImage (Recommended)**
44+
3845
1. Download the `.AppImage` file
3946
2. Make it executable: `chmod +x ocpp-cp-simulator_*.AppImage`
4047
3. Run: `./ocpp-cp-simulator_*.AppImage`
4148

4249
**Debian/Ubuntu**
50+
4351
1. Download the `.deb` file
4452
2. Install: `sudo dpkg -i ocpp-cp-simulator_*.deb`
4553
3. Or double-click to install with Software Center
@@ -60,6 +68,7 @@ npm run tauri:build
6068
```
6169

6270
#### Prerequisites for Development
71+
6372
- Node.js (v18 or later)
6473
- Rust (latest stable)
6574
- Platform-specific dependencies:
@@ -69,13 +78,10 @@ npm run tauri:build
6978

7079
<img width="1532" alt="image" src="https://github.com/user-attachments/assets/480f6e76-a426-4f0c-b133-a62a03f0847e">
7180

72-
7381
## Doc
7482

7583
https://deepwiki.com/shiv3/ocpp-cp-simulator
7684

77-
78-
7985
### Experimental feature
8086

8187
experimental feature support e.g. simultaneous use of multiple chargers

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"build": "vite build",
99
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1010
"preview": "vite preview",
11+
"format": "prettier --write .",
12+
"format:check": "prettier --check .",
1113
"prepare": "husky",
1214
"tauri": "tauri",
1315
"tauri:dev": "tauri dev",
@@ -48,7 +50,7 @@
4850
"vite": "^5.3.4"
4951
},
5052
"lint-staged": {
51-
"*.{ts,tsx}": "eslint --cache --fix",
52-
"*.{js,css,md}": "prettier --write"
53+
"*.{ts,tsx,js,jsx,css,md,json}": "prettier --write",
54+
"*.{ts,tsx}": "eslint --cache --fix"
5355
}
5456
}

scripts/generate-icon.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env node
22

3-
import { createWriteStream } from 'fs';
4-
import { mkdir } from 'fs/promises';
5-
import { dirname, join } from 'path';
6-
import { fileURLToPath } from 'url';
7-
import https from 'https';
3+
import { createWriteStream } from "fs";
4+
import { mkdir } from "fs/promises";
5+
import { dirname, join } from "path";
6+
import { fileURLToPath } from "url";
7+
import https from "https";
88

99
const __dirname = dirname(fileURLToPath(import.meta.url));
10-
const projectRoot = join(__dirname, '..');
11-
const iconsDir = join(projectRoot, 'src-tauri', 'icons');
10+
const projectRoot = join(__dirname, "..");
11+
const iconsDir = join(projectRoot, "src-tauri", "icons");
1212

1313
// Simple PNG generation using canvas-like approach
1414
async function generatePNG(size) {
@@ -17,41 +17,43 @@ async function generatePNG(size) {
1717
const svg = `<?xml version="1.0" encoding="UTF-8"?>
1818
<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}" xmlns="http://www.w3.org/2000/svg">
1919
<rect width="${size}" height="${size}" fill="#2563eb" rx="${size * 0.125}"/>
20-
<text x="${size/2}" y="${size * 0.6}" font-family="Arial, sans-serif" font-size="${size * 0.15}" font-weight="bold" text-anchor="middle" fill="#ffffff">OCPP</text>
20+
<text x="${size / 2}" y="${size * 0.6}" font-family="Arial, sans-serif" font-size="${size * 0.15}" font-weight="bold" text-anchor="middle" fill="#ffffff">OCPP</text>
2121
</svg>`;
22-
22+
2323
return svg;
2424
}
2525

2626
async function createIcons() {
2727
try {
2828
await mkdir(iconsDir, { recursive: true });
29-
29+
3030
// For now, create placeholder files
3131
// In a real implementation, you would convert SVG to PNG using a library like sharp or canvas
3232
const sizes = [
33-
{ name: '32x32.png', size: 32 },
34-
{ name: '128x128.png', size: 128 },
35-
{ name: '[email protected]', size: 256 },
33+
{ name: "32x32.png", size: 32 },
34+
{ name: "128x128.png", size: 128 },
35+
{ name: "[email protected]", size: 256 },
3636
];
37-
37+
3838
for (const { name, size } of sizes) {
3939
const svg = await generatePNG(size);
40-
const svgPath = join(iconsDir, name.replace('.png', '.svg'));
41-
40+
const svgPath = join(iconsDir, name.replace(".png", ".svg"));
41+
4242
await fs.writeFile(svgPath, svg);
4343
console.log(`Created placeholder for ${name}`);
4444
}
45-
45+
4646
// Create empty ico and icns files for now
47-
await fs.writeFile(join(iconsDir, 'icon.ico'), '');
48-
await fs.writeFile(join(iconsDir, 'icon.icns'), '');
49-
50-
console.log('Icon placeholders created. For production, convert these to proper formats.');
47+
await fs.writeFile(join(iconsDir, "icon.ico"), "");
48+
await fs.writeFile(join(iconsDir, "icon.icns"), "");
49+
50+
console.log(
51+
"Icon placeholders created. For production, convert these to proper formats.",
52+
);
5153
} catch (error) {
52-
console.error('Error creating icons:', error);
54+
console.error("Error creating icons:", error);
5355
process.exit(1);
5456
}
5557
}
5658

57-
createIcons();
59+
createIcons();

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
"targets": "all",
3030
"icon": []
3131
}
32-
}
32+
}

src/App.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
// App.tsx
22
import React from "react";
3-
import {BrowserRouter as Router, Route, Routes } from "react-router-dom";
3+
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
44
import Navbar from "./components/Navbar.tsx";
55
import Settings from "./components/Settings.tsx";
66
import TopPage from "./components/TopPage.tsx";
77

88
const App: React.FC = () => {
9-
10-
119
return (
1210
<Router basename={import.meta.env.VITE_BASE_URL}>
1311
<div className="min-h-screen bg-gray-100">
1412
<Navbar />
1513
<div className="container mx-auto my-auto p-4">
1614
<Routes>
17-
<Route path="/" element={<TopPage />} />
15+
<Route path="/" element={<TopPage />} />
1816
<Route path="/settings" element={<Settings />} />
1917
</Routes>
2018
</div>

0 commit comments

Comments
 (0)